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

[Solved] How to get the RadCombo box inside RadGridItem Template in CodeBehind

3 Answers 250 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Liji Jose
Top achievements
Rank 1
Liji Jose asked on 10 Feb 2010, 07:34 AM

 


 

<

 

telerik:RadGrid ID="gvSort" runat="server" >

 

 

<

 

telerik:GridTemplateColumn HeaderText="Column" HeaderStyle-Width="180px">

 

 

<ItemTemplate>

 

 

<telerik:RadComboBox runat="Server" Width="175px" ID="ColName" CssClass="ddlClass" AutoPostBack="true" EnableViewState="true"/>

 

 

</ItemTemplate>

 

 

<HeaderStyle Width="180px"></HeaderStyle>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:RadGrid >

I have a RadCombo box inside Radgrid , i need to get that Control in CodeBehind and Populate it Programatically ,
I tried using the Radgrid.FindControl() method but it is returning Nothing ..

 

Dim Cmb As New Telerik.Web.UI.RadComboBox

 

Cmb =

CType(gvSort.FindControl("ColName"), RadComboBox)

 




3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Feb 2010, 09:35 AM
Hello Liji Lose,

You can access the RadComboBox in ItemDataBound event of grid and then populate it.

C#:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            RadComboBox combo = (RadComboBox)item.FindControl("ColName"); 
            // Populate the combo 
        } 
    } 

Thanks,
Princy.
0
Liji Jose
Top achievements
Rank 1
answered on 10 Feb 2010, 10:11 AM
Thanks For u reply ,

The Controls inside the RadGrid ItemTemplate can only be Accessed inside  ItemDataBound Event ?
0
Iana Tsolova
Telerik team
answered on 10 Feb 2010, 10:25 AM
Hi Liji,

You can try handling the RadGrid ItemCommand event for your purpose as well. For instance as below:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExpandCollapseCommandName && !e.Item.Expanded)
    {
        GridDataItem item = e.Item as GridDataItem;
        GridNestedViewItem nestedItem = item.ChildItem;
        RadComboBox comboBox = nestedItem.FindControl("ColName") as RadComboBox;
    }
}

I hope this helps.

Greetings,
Iana
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
Liji Jose
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Liji Jose
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or