Solved

DataGrid Row Count

Posted on 2004-09-22
6
461 Views
Last Modified: 2010-04-15
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  

0
Comment
Question by:TariqRahim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 50 total points
ID: 12121384
Try this

datatable = datagrid.DataSource

count = datatable.rows.count();
0
 
LVL 6

Expert Comment

by:Chester_M_Ragel
ID: 12121560
Get the datasource of the Datagrid and cast that object to datatabel.
0
 
LVL 23

Expert Comment

by:Snarf0001
ID: 12137575
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
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question