To get the values from List and bind into Grid

Amatya
Posted by Amatya under ASP.NET category on | Points: 40 | Views : 269
void Page_Load()
{
// Build Country list
List<string> countryName = new List<string>();
countryName.Add(“INDIA”);
countryName.Add(“RUSSIA”);
countryName.Add(“AFRICA”);
countryName.Add(“JAPAN”);
// Bind to GridView
grdcountryName.DataSource = countryName;
grdcountryName.DataBind();
}


Below is my ASP code

<html xmlns=”http://www.w3.org/1999/xhtml” >
<head id=”Head1” runat=”server”>
<title>Show country List</title>
</head>
<body>
<form id=”form1” runat=”server”>
<div>
<asp:GridView
id=”grdcountryName”
Runat=”server” />
</div>
</form>
</body>
</html>


Thanks, Hope it help for starters :)

Comments or Responses

Login to post response