Add data using Textbox

  • Thread starter Thread starter Jason Huang
  • Start date Start date
J

Jason Huang

Hi,

New to C#, I'm trying using a Textbox and a commond button for adding a
record to a table, but don't know how. Please give me some suggestions.
Thanks.

Jason
 
Hi Jason,

You need to create a new DataRow from that table, then insert this row back into the table. The DataTable has a NewRow() method for creating blank rows with the proper columns.
 
Hi,
I think this will help you,Just drag one datagrid on your web form and write
the following code in page load event
DataTable dt=new DataTable("test");
DataRow dr;
dt.Columns.Add("ID");
dt.Columns.Add("Name");
dr=dt.NewRow();
dr[0]="1";
dr[1]="Table data";
dt.Rows.Add(dr);
DataGrid1.DataSource=dt;
DataBind();


Regards
Arindam
 
Back
Top