ArrayList
It is the set of Dissimilar data types.
It is under System.Collections NameSpace
Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>
</body>
</html>
Default.aspx.cs
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Data();
}
}
private void Data()
{
string[] arrlist = { "uday","raju","anvesh","kittu","sandhya" };
DataTable dt = new DataTable();
dt.Columns.Add("Name");
for (int i = 0; i < arrlist.Count(); i++)
{
dt.Rows.Add();
dt.Rows[i]["Name"] = arrlist[i].ToString();
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
It is the set of Dissimilar data types.
It is under System.Collections NameSpace
Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>
</body>
</html>
Default.aspx.cs
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Data();
}
}
private void Data()
{
string[] arrlist = { "uday","raju","anvesh","kittu","sandhya" };
DataTable dt = new DataTable();
dt.Columns.Add("Name");
for (int i = 0; i < arrlist.Count(); i++)
{
dt.Rows.Add();
dt.Rows[i]["Name"] = arrlist[i].ToString();
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
No comments:
Post a Comment
Thank you for visiting my blog