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

RadGrid - Modify it's datasource before binding

1 Answer 171 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 28 Jul 2011, 12:01 AM


Is it possible to modify the SqlDataSource of a RadGrid, before it gets bound to the grid?

In my example I have query that is returning sets of data with the following column names.

Parameter1Title
Parameter1Value
Parameter2Title
Parameter2Value
Parameter3Title
Parameter3Value


What I need to do is sort of normalize this set into just two columns that contains only the ones that have a value.

For example, imagine the returned set contains these values.

Parameter1Title   "Age"
Parameter1Value   "45"
Parameter2Title   null
Parameter2Value   null
Parameter3Title   "Color"
Parameter3Value   "Blue"


From this I need to created an SqlDataSource that holds the following info for the grid

Parameter   Value
"Age"       "45"
"Color"     "Blue"

Where the 2nd parameter set was ignored as it had no value.

Note also, this Parameter grid is a child grid to grid called Attributes. That is, it's SqlDataSource is fed the AttributeID as the rows on the Attribute grid as clicked.

Where would I make this change? That is, intercept before the data is bound to the grid? Also, am I better off creating a new DataSet to bind to the grid? Is that possible with the RadGrid?





1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 03 Aug 2011, 03:59 PM
Hello Brad,

You can try adding another layer between the RadGrid and your datasource. Create your own logic that handles the empty parameters in the desired way and then pass the resulting data (DataSet, IEnumerable, etc) using advanced data-binding.

Regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
General Discussions
Asked by
Brad
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or