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

Model Binding: SelectMethod defined in a Business Object.

1 Answer 243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 07 Jan 2015, 03:42 PM
I am trying to use the ASP.NET 4.5 Model Binding features of RadGrid in version 2013.3.1114. My SelectMethod is defined in a Business Object. RadGrid throws an exception indicating that it cannot find the method on the page.

I have implemented the OnCallingDataMethods event:

protected void CallingDataMethods(object sender, CallingDataMethodsEventArgs e)
{
    e.DataMethodsObject = new BLL();
}

However, RadGrid still attempts to locate the SelectMethod on the page object. Using the OnCallingDataMethods event of RadComboBox works correctly, so I am surprised that it is not working for RadGrid.

Has this been resolved in newer versions of RadGrid? If not, what are my options?

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 12 Jan 2015, 08:26 AM
Hi Scott,

When working with Model Binding and RadGrid, handling the OnCallingDataMethods only for the RadGrid itself will not be enough. In order to get this working you will have to handle the MasterTableView's OnCallingDataMethods event as well:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" OnCallingDataMethods="RadGrid1_CallingDataMethods">
    <MasterTableView SelectMethod="GetProducts"></MasterTableView>
</telerik:RadGrid>

And the code-behind:
protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
 
    RadGrid1.MasterTableView.CallingDataMethods += MasterTableView_CallingDataMethods;
}
 
void MasterTableView_CallingDataMethods(object sender, CallingDataMethodsEventArgs e)
{
    e.DataMethodsObject = new TestCustomObject();
}
 
protected void RadGrid1_CallingDataMethods(object sender, CallingDataMethodsEventArgs e)
{
    e.DataMethodsObject = new TestCustomObject();
}

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or