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

Set Grid Hierarchy Programmatically

5 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 04 Apr 2011, 11:58 AM
Hi,
I have a requirement to build a RadGrid entirely programmatically that is capable of:
a) Filtering
b) Showing a detail table

In order to get filtering working I can't use simple databinding with a dataset so I've chosen to use an ObjectDataSource . The problem is that I can't seem to set the "SelectParameters" for the ObjectDataSource that populates the detail table (you seem to only be able to do this declaratively).  

////Create ObjectDataSource for Detail table
            myDataTable2 = new DataTableWrapper(sourceDataTable2);
            t = myDataTable.GetType();
            objDataSource = new ObjectDataSource();
            objDataSource.ID = "myDataSource2";
            objDataSource.TypeName = t.AssemblyQualifiedName;
            objDataSource.SelectMethod = "GetDetailTable";
            //objDataSource.SelectParameters <-- need to set this somehow but it is readonly!!!!
            objDataSource.ObjectCreating += new ObjectDataSourceObjectEventHandler(objDataSource2_ObjectCreating);
            this.Controls.Add(objDataSource);


If anyone can help me I'd appreciate it.

Thanks,

Nick

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Apr 2011, 01:30 PM
Hello Nick,

Take a look at the following demo.
Grid / Creating Hierarchy Programmatically

Thanks,
Shinu.
0
Pavlina
Telerik team
answered on 04 Apr 2011, 01:35 PM
Hi Nick,

To create the hierarchy grid programmatically you need to define its structure into the Page_Init event handler. Please check out the following online example which demonstrates how to archive the desired functionality:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/hierarchy/defaultcs.aspx

Greetings,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Nick
Top achievements
Rank 1
answered on 04 Apr 2011, 01:38 PM
Hi Shinu,

Thanks for responding. Unfortunately the demo you suggested doesn't help as I need to do this programmatically, the demo requires you to declaratively setup the SelectParameters for the ObjectDataSource which won't work for me as I don't know them at design time.

Any other ideas would be appreciated.

Thanks,

Nick
0
Nick
Top achievements
Rank 1
answered on 04 Apr 2011, 01:44 PM
Hi Pavlina ,
Thanks for suggestion, but it has the same problem as the one suggested by Shinu.
I'm trying to bind the grid entirely in the code behind, I can't use declarative statements such as:

<SelectParameters>
                <asp:Parameter Name="CustomerID" Type="string" />
            </SelectParameters>

Any other ideas?

Thanks,

Nick
0
Pavlina
Telerik team
answered on 07 Apr 2011, 10:32 AM
Hi Nick,

I suggest that you go through the following link:
http://stackoverflow.com/questions/235166/how-do-i-set-up-objectdatasource-select-parameters-at-runtime

Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Nick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Pavlina
Telerik team
Nick
Top achievements
Rank 1
Share this question
or