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

grd_itemdataboundcommand on grid with details table

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carina
Top achievements
Rank 1
Carina asked on 10 Jan 2013, 11:12 PM
Hi, I was wondering how I could go about the code behind on this. I have my grid which display records and can filter by active, inactive, etc... then when I want to look at further details, the details table does not populate and now I am getting an error on:

If

 

 

e.Item.ItemType = GridItemType.Item OrElse e.Item.ItemType = GridItemType.AlternatingItem Then

 

 

 

 

Dim record As table 1 = e.Item.DataItem<----------

 


that says:

Unable to cast object of type 'xxx.Model.database.table2' to type 'xxx.Model.database.table1' .

what is going on here?

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 11 Jan 2013, 05:37 AM
Hello,

<MasterTableView  Name="Parent">
              <Columns>          
              </Columns>
              <DetailTables>
                  <telerik:GridTableView Name="Child">
                  </telerik:GridTableView>
              </DetailTables>
          </MasterTableView>
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
  {
   
 
      if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Parent")
      {
          // Parent table
      }
      else if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Child")
      {
          // Child table
      }
  }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Carina
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or