|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 76
|
I have a dataset with a tableadapter in
I want to link the grid to the tableadapter using an ObjectDataSource as I would with a VS Grid
The grid has a DataSourceID which I've set to the ObjectDataSource (dataset), plus the DataTable property I've entered the tableadapter usesTableAdapter.vw_aspnet_MembershipUsersTableAdapter
In pageload I put Grid1.DataBind() but get the error message:
The Grid control does not support DataSourceID. Please fill a DataTable from the data source control, then populate the Grid from the DataTable.
The error message is telling me it doesn't support DataSourceID although there is a DataSourceID property on the control.
I'm confused as to how I'm suppose to bind the grid to an ObjectDataSource (dataset table adapter)?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The Grid inherited DataSourceID from its base class but it doesn't use it. That's why we put an error message there when you try to use it. As for how to bind the Grid to ObjectDataSource --- you don't. You bind the Grid to objects that Grid recognizes. You can find information about what object the Grid can bind to at here: http://www.essentialobjects.com/ViewDoc.aspx?t=Grid%2fdata_binding.htmlWe are working to support DataSourceID but we will be starting from SqlDataSource at the very beginning. So ObjectDataSource might take a while. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 10/21/2009 Posts: 39
|
I am using version 8, 0, 17, 2 of the grid. I have successfully bound the grid to an ObjectDataSource but when I enable paging and set the RecordCount, I get the correct number of rows returned and the correct number of pages displayed, but there are no paging controls visible to page through the pages. How should I enable paging? The RecordOffset variable is read only. I looked at your sample code here: http://doc.essentialobjects.com/library/1/grid/data_binding.aspx but that uses a very simple query. I need to use a stored procedure to get the data. Please advise. Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That usually means your RecordCount is not set correctly. RecordCount should be the total record count including all pages. For example, if you have 100 records in your DB and you display 10 records per page, then you RecordCount should be set to 100.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 10/21/2009 Posts: 39
|
I am tring to set the record count but it doesn't seem to be taking effect. My code is: int recCount = 1709; GridRates.RecordCount = recCount; GridRates.DataSourceID = "ObjectDataSource1"; GridRates.DataBind(); GridRates.RecordCount is equal to 10 after I set it to 1709 and after I call DataBind it is equal to 0.
What am I doing wrong?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
To use server side paging, you must set the following properties:
1. RunningMode to Server; 2. AllowPaging to true; 3. RecordCount to the total number of records;
To use client side paging, you must set the following properties: 1. RunningMode to Client; 2. AllowPaging to true;
If you still have problems, please try to compare your code with the sample code. Whether you are using a stored procedure to retrieve the data is irrelevant.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 10/21/2009 Posts: 39
|
Setting the Running Mode to Server solved the issue that were no paging controls to change the current page, thanks. Now clicking on the different page numbers below the grid does nothing. The fist page is always displayed. When I debug and step through the code I notice that there are no calls to the serverside ObjectDataSource methods ObjectDataSource1_Selecting and RatePlanSelectAllPaged. When I replace your grid with the default ASP.NET Gridview there are 2 calls to ObjectDataSource1_Selecting and 1 call to RatePlanSelectAllPaged every time a different page number is selected. Please help.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That is normal. Our Grid does not call the data source's paging methods. You will need to handle the Grid's PageIndexChanged event to rebind the Grid.
Thanks!
|
|