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

[Solved] Adding control to FooterTemplate of GridDropDownColumn

2 Answers 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tushar Jain
Top achievements
Rank 1
Tushar Jain asked on 27 Jul 2009, 07:36 PM
Hi,
I have a RadGrid which displays all records in 'InPlace' edit mode.  One of the columns in the grid is a GridDropDown column. Since I cannot add a FooterTemplate to this column directly, I do the following in the ItemDataBound event:

if (e.Item is GridFooterItem)
{
   GridFooterItem footer = (GridFooterItem)e.Item;
   RadComboBox radComboStatus = new RadComboBox();
   radComboStatus.ID = comboId;
   .
   .

   footer["DisplayStatus"].Controls.Add(radComboStatus);
            
}


This allows me to display the combo box in the footer. However, I am not able to access this control on the serverside during a postback (caused by a button in the footer of some other column). I am able to access other controls in the footer that were added during design time using the footertemplate.

Thanks in advance for you help

TJ

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Jul 2009, 05:38 AM
Hi Tushar Jain,

Try adding the RadComboBox in ItemCreated event instead of ItemDataBound and then try the following code snippet in order to access the RadCombBox from code behind.

C#:
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    if (e.Item is GridFooterItem) 
    { 
        GridFooterItem footer = (GridFooterItem)e.Item; 
        RadComboBox radComboStatus = new RadComboBox(); 
        radComboStatus.ID = "comboId"
        footer["DisplayStatus"].Controls.Add(radComboStatus); 
    } 
 
protected void Button1_Click(object sender, EventArgs e) 
    GridFooterItem footer = (GridFooterItem)RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0]; 
    RadComboBox combo = (RadComboBox)footer["DisplayStatus"].FindControl("comboId"); 
Hope this helps :)

-Shinu.
0
Tushar Jain
Top achievements
Rank 1
answered on 28 Jul 2009, 06:29 PM
That worked like a charm....thanks for your fast and precise response....greatly appreciated.

Tushar
Tags
Grid
Asked by
Tushar Jain
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tushar Jain
Top achievements
Rank 1
Share this question
or