G
Guest
How do you add a new row to the datagrid windows control one row at a time without overwriting the existing row
Thanks a lot
Obi
Thanks a lot
Obi
without overwriting the existing row ?Obi Oberoi said:How do you add a new row to the datagrid windows control one row at a time
without overwriting the existing rowObi Oberoi said:How do you add a new row to the datagrid windows control one row at a tim
getting the "object reference not set error". I know what this error means,Obi said:Hi William,
Thanks for the suggestion. I've converted the code in vb.net, but I'm
Try
Dim dr As DataRow
Dim dt As New DataTable
Dim ds As New DataSet
dr = ds.Tables(0).NewRow
dr.Item("FirstName") = txtCol1.Text
dr.Item("LastName") = txtCol1.Text
ds.Tables(0).Rows.Add(dr)
Catch ex As SqlException
ex.Message.ToString()
End Try
----- William Ryan eMVP wrote: -----
DataRow dro = DataSet.Tables[Index].NewRow();
//Set the values accordingly, I'm using Strings and an Int, but you should
use values that match the columns of your datatable.
dro[0] = "FirstValue";
dro[1]= "SecondValue";
dro[2] = SomeIntValue;
DataSet.Tables[Index].Rows.Add(dro);
a timeObi Oberoi said:How do you add a new row to the datagrid windows control one row at
without overwriting the existing row ?