Link to home
Start Free TrialLog in
Avatar of TariqRahim
TariqRahim

asked on

DataGrid Row Count

I assgned a empty DataTable as data Source to the Datagrid. Now i entered the data in
the datagrid rows and this data i want to assing to the datatable and then update to database
for this i want the rows count of the grid to know how much rows i entered in the grid and then
manually assign this griddata to that datatable by loop.... for this i dont know how
 I CAN GET THE ROW COUNT OF DATAGRID CONTROL ......

I also made type cast of datagrid to datatable and then tried to get count but in this way it
gives me the row count of that empty datatabel which i assigned to datagrid as datasource.

PLEASE REPLY ME AS SOON AS .... I STRUCKED AT THIS POINT  

ASKER CERTIFIED SOLUTION
Avatar of 123654789987
123654789987

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chester_M_Ragel
Chester_M_Ragel

Get the datasource of the Datagrid and cast that object to datatabel.
Avatar of Snarf0001
Is this web or windows?

If it's windows forms, you don't need to loop through and populate the datatable.  Once a grid is bound, everything you do on the grid is reflected in the bound datasource at the same moment, so your added rows will already be in there.

If it's aspx, it's DataGrid.Items.Count