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

Populate RadComboBox in an EditTemplate

1 Answer 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Leo
Top achievements
Rank 1
Leo asked on 26 Feb 2009, 07:54 PM
Hi -

I have a RadGrid with the following EditTemplate and I need to populate the ddlPeatBU RadComboBox:

 

<telerik:GridTemplateColumn DataField="PeatBusinessUnitName" FilterImageUrl="../images/arrow_dn.gif"

 

 

SortAscImageUrl="../images/SortAsc.gif" SortDescImageUrl="../images/SortDesc.gif"

 

 

HeaderText="PEAT Business Unit" SortExpression="PeatBusinessUnitName" UniqueName="PeatBusinessUnitName"

 

 

Visible="true" AllowFiltering="true">

 

 

<HeaderStyle CssClass="RadGridHeader" Width="19%" />

 

 

<ItemStyle Width="19%" />

 

 

<ItemTemplate>

 

 

<asp:Label Text='<%# Eval("PeatBusinessUnitName") %>' runat="server" Width="220" ID="lblPeatBUName"></asp:Label></ItemTemplate>

 

 

<EditItemTemplate>

 

 

<telerik:RadComboBox ID="ddlPeatBU" Width="99%" runat="server" >

 

 

</telerik:RadComboBox>

 

 

<asp:RequiredFieldValidator ID="PeatBURequired" runat="server" ControlToValidate="ddlPeatBU"

 

 

ErrorMessage="Peat BU Required," Display="Dynamic"></asp:RequiredFieldValidator>

 

 

</EditItemTemplate>

 

 

</telerik:GridTemplateColumn>

How can I do this?

Thanks,
Leo

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Feb 2009, 04:42 AM
Hi Leo,

Try the following code snippet to populate RadComboBox when RadGrid in edit mode.

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) 
    { 
        GridEditFormItem insertItem = (GridEditFormItem)e.Item; 
        RadComboBox combo = (RadComboBox)insertItem.FindControl("ddlPeatBU"); 
        combo.DataSourceID = "SqlDataSource1"
        combo.DataTextField = "CustomerID"
        combo.DataValueField = "CustomerID"
        combo.DataBind();   
    }  

Thanks,
Shinu.
Tags
Grid
Asked by
Leo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or