JamesAStewart
asked on
Get RowCount or RecordCount
I'm using a paged GridView to display data through an ObjectDataSource and pass paramaters to a DataSet.
The ObjectDataSource connects to a DataSet which contain TableAdapters which inturn connect to the SQL Stored Procedures.
I need to obtain the RecordCount based on the current set of results that have been returned (i.e. for the entire GridView).
I would be grateful for any help.
Using ASP.Net 2.0 VB
The ObjectDataSource connects to a DataSet which contain TableAdapters which inturn connect to the SQL Stored Procedures.
I need to obtain the RecordCount based on the current set of results that have been returned (i.e. for the entire GridView).
I would be grateful for any help.
Using ASP.Net 2.0 VB
I am not sure I entirely understand your question.
If you have a dataset that contains 23 records and your gridview is set to display 10 records at a time, do you want to return 10 as the 1st gridview page count, 10 as the 2nd gridview page count and 3 for the 3rd gridview page count?
Or do you want to return 23 the total number of records in the dataset?
If you have a dataset that contains 23 records and your gridview is set to display 10 records at a time, do you want to return 10 as the 1st gridview page count, 10 as the 2nd gridview page count and 3 for the 3rd gridview page count?
Or do you want to return 23 the total number of records in the dataset?
ASKER
I need to return the total number of records returned by the objectDataSource.
Use the "Selected" declaration for your ObjectDataSource like so:
Private Sub ObjectDataSource1_Selected (ByVal sender As Object, ByVal e As System.Web.UI.WebControls. ObjectData SourceStat usEventArg s) Handles ObjectDataSource1.Selected
'Now, utilize the following code within that subroutine:
Dim numRows As Integer = (e.ReturnValue).Tables(0). Rows.Count
End Sub
Private Sub ObjectDataSource1_Selected
'Now, utilize the following code within that subroutine:
Dim numRows As Integer = (e.ReturnValue).Tables(0).
End Sub
ASKER
I get:
Public member 'Tables' on type 'myStoredprocedureDataTabl e' not found.
Public member 'Tables' on type 'myStoredprocedureDataTabl
There will be a point in your code where you fill a dataset. Let us assume this dataset is named "ds". The fill may look something like this:
// Populate DataSet
DataSet ds = new DataSet();
da.Fill(ds, "FormDef");
After the Fill Command has been executed, you can use this statement to provide the rowcount.
ds.Tables[0].Rows.Count
Hope this helps. If it doesn't, can you post the code you have created up to this point?
// Populate DataSet
DataSet ds = new DataSet();
da.Fill(ds, "FormDef");
After the Fill Command has been executed, you can use this statement to provide the rowcount.
ds.Tables[0].Rows.Count
Hope this helps. If it doesn't, can you post the code you have created up to this point?
>> Public member 'Tables' on type 'myStoredprocedureDataTabl e' not found.
Can you show how you select your data with the ObjectDataSource
Can you show how you select your data with the ObjectDataSource
ASKER
In this particular case, I've not written code to connect the ODS. I've simply dragged it from the toolbar onto my application, set it up so that the appropriate values are sent to the stored procedure then bound it to a gridview.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
But if you want the rrow count of the dataset then use
Datasetname.tables[0].rows
DatasetName.(which ever table you want from dataset).rows.count basic way of getting the row count froma dataset.
the code is in the c# language.