Solved

DataGrid Row Count

Posted on 2004-09-22
6
450 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
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 22

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now