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

[Solved] Getting GridException when searching for footer in Hierarchical Grid

1 Answer 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg Smith
Top achievements
Rank 1
Greg Smith asked on 21 Jan 2010, 07:57 PM
I followed the HowTo on setting footer values in the code behind, but I'm getting a GridException because the footer value I'm looking for doesn't exist in the Detail Table, but the ItemDataBound is fired for all tables.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
        
if (e.Item is GridDataItem)
       {
           GridDataItem dataItem = (GridDataItem)e.Item;
           sum+=
double.Parse((dataItem[ "Template1"].FindControl("TextBox1") as TextBox).Text);
       }
        
else if (e.Item is GridFooterItem)
       {
           GridFooterItem footer = (GridFooterItem)e.Item;
           (footer[
"Template1"].FindControl("TextBox2") as TextBox).Text = sum.ToString();
           clientID = (footer[
"Template1"].FindControl("TextBox2") as TextBox).ClientID;
       }
   }


The bold line above throws the exception because the ItemDataBound was triggered by the Detail table which doesn't have a "Template1" column. How can I check for the existence of the "Template1" column thereby preventing the exception?


Thanks
Greg

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Jan 2010, 05:32 AM
Hello Greg,

You can differentiate between the tableview instances in a hierarchical grid using their Name property. Check out the following document which explains on how this can be done:
Distinguish grid rows in hierarchy on ItemCreated/ItemDataBound

Thanks
Princy.
Tags
Grid
Asked by
Greg Smith
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or