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

Different data sources for a detail table in hierarchical grid

2 Answers 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SP
Top achievements
Rank 1
SP asked on 03 Feb 2011, 04:05 PM
Hi,

I have a Hierarchical grid with several detail table levels.  I'm using the DetailTableDataBind method as below to set each detail tables data source however at the last level depending on certain criteria i need to bind to a different source for each item.  This works fine but if there are more than 2 items in this last detail table the columns displayed are always from the first item expanded.  (Autogenerate columns is set to true on the last detail table as i don't always know the columns that are going to be returned.)  Is there any way to show the columns from each individual data source?

switch (e.DetailTableView.Name)
        {
            case "tbl1":
                {
                     //setting the detailtableview datasource here
                    break;
                
            case "tbl2":
                {
                     //setting the detailtableview datasource here

                            if(condition 1)
                            {
                                e.DetailTableView.DataSource = source1;
                            }
                            else
                            {
                                e.DetailTableView.DataSource = source2;
                            }
                    break;
                }

        }


Many Thanks

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Feb 2011, 09:09 AM
Hello SP,

I am not quite sure about the issue. I guess you are populating each child TableView based on it parent row. Check whether you are getting correct parent keyValue when clicking each child item(ie, for each child TableView).

C#:
protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
   switch (e.DetailTableView.Name)
        {
            .   .   .  .  .   .
            case "tbl2":
                {
                 string keyvalue = (string)e.DetailTableView.ParentItem.GetDataKeyValue("KeyValue");
                 //check this value for each item
                }
        

Hope this helps,
Princy.
0
Krishna
Top achievements
Rank 1
answered on 24 Sep 2011, 05:54 PM

Hello SP,

I need to code my grid the same way, the details table varies depends on parent row, Can you please share your code with me both .aspx and .cs?

Thanks,
Krishna.
Tags
Grid
Asked by
SP
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Krishna
Top achievements
Rank 1
Share this question
or