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

[Solved] RadComboBox not keeping value in EditItemTemplate

3 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
Daniel asked on 10 Dec 2009, 01:33 AM
Hi. I've got a RadComboBox inside an EditItemTemplate that gets populated in the code behind. It needs to get populated in the code behind because the list it shows is specific to the parent table. When I perform an automatic update everything updates except this one RadComboBox. Thanks.

C#
protected void rgEnvironments_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode && e.Item.OwnerTableView.Name != "environments"
        { 
            GridDataItem dataItem = e.Item.OwnerTableView.ParentItem; 
            int id = Intranet.Str2Int(dataItem.GetDataKeyValue("system_id").ToString()); 
            GridEditableItem moduleEdited = (GridEditableItem)e.Item; 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            Literal msv = (Literal)moduleEdited.FindControl("ltlModuleEdit"); // Grab selectedvalue from hidden literal 
            RadComboBox moduleCombo = (RadComboBox)moduleEdited["module"].FindControl("rcbModule"); 
            moduleCombo.DataSource = GetModuleDataTable(id); 
            moduleCombo.DataTextField = "module"
            moduleCombo.DataValueField = "module_id"
            moduleCombo.DataBind(); 
            if (null != msv) 
                moduleCombo.SelectedValue = msv.Text; 
        } 
    } 

ASPX
<telerik:GridTemplateColumn HeaderText="Module" UniqueName="module" HeaderStyle-Width="16%"
                                                        <ItemTemplate> 
                                                            <asp:Literal ID="ltlModule" Text='<%# Bind("module") %>' runat="server" /></ItemTemplate
                                                        <EditItemTemplate> 
                                                            <asp:Literal ID="ltlModuleEdit" Text='<%# Bind("module_id") %>' Visible="false" runat="server" /> 
                                                            <telerik:RadComboBox ID="rcbModule" runat="server" Skin="Default" /> 
                                                        </EditItemTemplate> 
                                                    </telerik:GridTemplateColumn> 






3 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
answered on 15 Dec 2009, 12:44 AM
No takers?
0
Yavor
Telerik team
answered on 15 Dec 2009, 09:05 AM
Hello Daniel,

 When you are performing automatic operations, the combo must point to the datasource which supplies data to the grid. When the combo is populated from the code-behind, there is no way for the data to be passed to the appropriate update parameter(s). If you would like to preserve the present setup, you can handle the whole update/delete/insert functionality from the code behind - you can intercept the newly entered values there, and propagate the changes to the database.
I hope this information helps.

Regards,
Yavor
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
answered on 16 Dec 2009, 04:41 AM
Thanks for the response Yavor. That it what I thought, I was just checking if it was possible for automatic operations. Thanks again.

Daniel
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
Yavor
Telerik team
Share this question
or