How to show list values in ASP NET?

We want to display a simple list of data values in an ASP NET web page.

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.UI;
 using System.Web.UI.WebControls;
public partial class Customer_Details : System.Web.UI.Page
             public class myCustomer {
             public String Name {get;set;}
             public int Age { get; set; }
             public String City { get; set; }
             public myCustomer()
public myCustomer(string _name, int _age, string _city)
                 Name = _name;
                 Age = _age;
                 City = _city;
List<myCustomer> customerList;
protected void Page_Load(object sender, EventArgs e)
             customerList = new List<myCustomer>();
             myCustomer co1 = new myCustomer { Name = "Rohit", Age = 25, City = "Kolkata" };
             myCustomer co2 = new myCustomer("Manish", 27, "Mumbai");
             myCustomer co3 = new myCustomer("Priya", 22, "Goa");
             testDataGrid.DataSource = customerList;

<%@ Page Language="C#" CodeFile="customer_details.aspx.cs" Inherits="Customer_Details" %>
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
    <asp:Repeater id="testDataGrid" runat="server" >
            <tr><td>Name:</td><td><asp:TextBox  ID="Customer Name" Text= '<%# Eval("Name") %>' visible="true"/> </td></tr>
            <tr><td>Age:</td><td><asp:TextBox ID="Age" Text= '<%# Eval("Age") %>'visible="true" /></td></tr>
            <tr><td>City:</td><td><asp:TextBox  ID="City" Text='<%# Eval("City") %>' visible="true" /></td></tr>


Name: Rohit
Age: 25
City: Kolkata

Name: Manish
Age: 27
City: Mumbai

Name: Priya
Age: 22
City: Goa

Leave a Reply

Your email address will not be published. Required fields are marked *