Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: How to add new Row in DataTable on clickEvent.


Message #1 by "RAJESH P. (BEACONSOFT)" <RAJESHP@b...> on Thu, 9 Jan 2003 17:18:15 +0530

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


  Return to Index