I went through the demo of hierarchical RadListView, is there a way to do databinding in server-side instead of using SqlDataSource control?
Thanks.
2 Answers, 1 is accepted
0
Tsvetina
Telerik team
answered on 21 Jun 2012, 08:24 AM
Hi Shannnon,
As mentioned in the other forum thread, you can bind the listviews using their OnNeedDataSource server event. In it, you can cast sender to RadListView and get its NamingContainer which should be the parent RadListViewDataItem. From it, you can pick the ProductID and use it to query the database, something like:
RadListViewDataItem parentItem = (sender as RadListView).NamingContainer as RadListViewDataItem;
string id = (parentItem.FindControl("HiddenField1") as HiddenField).Value;
(sender as RadListView).DataSource= //query db for records having this ID
}
For this to work, declare an asp:HiddenField bound to the ProductID value.
Greetings,
Tsvetina
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.
Also, I found another way to do it. On parent RadListView's OnItemDataBound event, use RadListView rlv2 = e.Item.FindControl("NestedRadListView1") as RadListView to get the instance of the nested radlistview, and use a hiddenField to get the childTable's query value and data bind the table to rlv2, and if there is one more nested listView in rlv2, use the same step that treats rlv2 as parent list view and specify the nested child view's datasource in rlv2's OnItemDataBound. this way, you can bind multiple nested radlistview in server side.