I have created two TextBoxes to enter the FirstName and LastName of an employee in a web-based ASP.NET application using C# on Visual studio 2010. There is a Button. when I click on it, the values that I enter in the TextBoxes should be displayed in a Gridview without those values being stored in the database. I have already implemented it using DataTables as shown below. But now I want to implement it using ArrayList. How can I do that? Can you provide a sample code to execute the above mentioned functionality?
How can I tweak the code given below, to implement the functionality using ArrayList instead of DataTables?
**
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("FIRST NAME");
DataColumn dc2 = new DataColumn("LAST NAME");
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
DataRow dr1 = dt.NewRow();
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
DataRow dr1 = dt.NewRow();
dr1[0] = TextBox1.Text;
dr1[1] = TextBox2.Text;
dt.Rows.Add(dr1);
GridView1.DataSource = dt;
GridView1.DataBind();
}
**