Solved

DataGrid Row Count

Posted on 2004-09-22
6
449 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
Comment Utility
Try this

datatable = datagrid.DataSource

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

Expert Comment

by:Chester_M_Ragel
Comment Utility
Get the datasource of the Datagrid and cast that object to datatabel.
0
 
LVL 22

Expert Comment

by:Snarf0001
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

10 Experts available now in Live!

Get 1:1 Help Now