This is a migrated thread and some comments may be shown as answers.

RadGrid DataBind calls ObjectDataSource Select 3 Times

2 Answers 207 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joan
Top achievements
Rank 1
Joan asked on 22 Dec 2011, 06:47 AM
Hello,

I've seen this question asked before and I saw no appropriate resolution.

I have a RadGrid that is just a single level, no detail tables, no nesting.  The ObjectDataSource is set on the grid in code behind in response to a search button.
PayrollByCandidateRadGrid.DataSource = PayrollByCandidateObjectDataSource
PayrollByCandidateRadGrid.DataBind()
PayrollByCandidateRadGrid.Visible = True

The DataBind() method calls the ObjectDataSource.Select method 3 times before the third line of code above runs.
If I put a break point at the End Function of the ObjectDataSource code, I see the following in the Immediate Window:
F11 after first call
 
Step into: Stepping over non-user code 'System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod'
Step into: Stepping over non-user code 'System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect'
Step into: Stepping over non-user code 'System.Web.UI.DataSourceView.Select'
Step into: Stepping over non-user code 'Telerik.Web.UI.RadGrid.DataBind'
 
F11 after second call
 
Step into: Stepping over non-user code 'System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod'
Step into: Stepping over non-user code 'System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect'
Step into: Stepping over non-user code 'System.Web.UI.DataSourceView.Select'
 
F11 after third call
 
Step into: Stepping over non-user code 'System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod'
Step into: Stepping over non-user code 'System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect'
Step into: Stepping over non-user code 'Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource'
Step into: Stepping over non-user code 'Telerik.Web.UI.GridTableView.ResolvedDataSource.get'
Step into: Stepping over non-user code 'Telerik.Web.UI.GridTableView.CreateChildControls'
Step into: Stepping over non-user code 'System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding'
Step into: Stepping over non-user code 'System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback'
Step into: Stepping over non-user code 'Telerik.Web.UI.GridTableView.PerformSelect'
Step into: Stepping over non-user code 'Telerik.Web.UI.GridTableView.DataBind'

I also have other RadGrids on the page in various tab/multipage areas and they all have detailtables or nesting of some kind.  They all call their ObjectDataSource.Select methods 3 times as well, so I thought I'd just do the testing with the single level Grid.

Your assistance with this matter will make the sale of the product and save me from the wrath of my DBA.

Regards,
Joan.

2 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 27 Dec 2011, 02:26 PM
Hello,

The RadGrid.DataSource gets or sets the object from which the Telerik RadGrid control retrieves its list of data items. However assigning a data source control to this property is a wrong usage of it. In order to achieve the desired functionality you need to use RadGrid.DataSourceID property. For example:
RadGrid1.DataSourceID = "ObjectDataSourceID";
RadGrid1.DataBind();
RadGrid1.Visible = true;
I am sending you a simple example which demonstrates how to bind the RadGrid to ObjectDataSource on button click. Also on the following link I attached a small video which demonstrates how the example works on my end.
Additionally please check out the following documentation articles which explain server side databinding of the RadGrid:
http://www.telerik.com/help/aspnet-ajax/grid-simple-data-binding.html
http://www.telerik.com/help/aspnet-ajax/grid-advanced-data-binding.html
http://www.telerik.com/help/aspnet-ajax/grid-binding-to-declarative-datasource-controls.html

I hope this helps.

Greetings,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Joan
Top achievements
Rank 1
answered on 28 Dec 2011, 01:18 AM
Thank you so much, Radoslav, for the prompt reply.  The solution for me was to set the DataSourceID and not call DataBind().
Tags
Grid
Asked by
Joan
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Joan
Top achievements
Rank 1
Share this question
or