Reputation:
I am filling my datatable from databse sa
var z = from ins in cstmrDC.customersCntcts_rd(101)
select ins;
foreach (var dtbl in z)
{
DataRow drDtls;
drDtls = dtDtls.NewRow();
drDtls[0] = dtbl.cust_Slno;
drDtls[1] = dtbl.cust_Cntctnm;
drDtls[2] = dtbl.cust_Cntctdesig;
drDtls[3] = dtbl.cust_Cntctmobl;
drDtls[4] = dtbl.cust_Cntctmail;
//drDtls.RowState = DataRowState.Unchanged;
dtDtls.Rows.Add(drDtls);
}
In this way I can fill my DataTable
, but the RowState
of the DataTable
is set to Added
by default. But I want to manipulate these records from DataGridView
.
Without changing the RowState
, how can I insert, delete and update my DataGridview
? Help me to fill the data table directly from the database.
I tried using CopyToDataTable()
that is apperaring in my IntelliSense box. Maybe this is because I am using .Net 3.5.
Please Help me..
Upvotes: 0
Views: 1206
Reputation: 109205
Just do
...
dtDtls.Rows.Add(drDtls);
dtDtls.AcceptChanges();
...
and RowState
will be Unchanged
.
Upvotes: 0