aspx_beginners thread: How to add new Row in DataTable on clickEvent.
How to add new Row in DataTable from Html Control at runtime.I am
getting the Same instead of new one.
This my Code.
void ShowAuthors(Object Sender, EventArgs E)
{
DataTable objTable =3D new DataTable("NewTable");
objTable.Columns.Add("Author",Type.GetType("System.String"));
objTable.Columns.Add("Book",Type.GetType("System.String"));
objTable.Columns.Add("Price",Type.GetType("System.String"));
DataRow objDataRow;
objDataRow =3D objTable.NewRow();
objDataRow["Author"] =3D Request.Form["T1"];
objDataRow["Book"] =3D Request.Form["T2"];
objDataRow["Price"] =3D Request.Form["T3"];
objTable.Rows.Add(objDataRow);
objDataRow =3D objTable.NewRow();
}
<asp:Button Text=3D"Show Authors" OnClick=3D"ShowAuthors"
runat=3D"server"/>
I am calling this function on click event.Pls Tell me How to add NewRow
on eachClick.
Thanks
P.Raajesh