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

How do you display current values of a row in RadGrid EditFormTemplate on Update mode?

1 Answer 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 19 Feb 2015, 06:19 PM
Hello,

I have a RadGrid, this RadGrid uses an Edit Form Template containing multiple controls for user input. In particular, I am interested in how I can add existing values to a RadComboBox which has multiple checkbox options when the edit form is opened.

Currently, I have methods to get all the values I need to check from my database. I also have all other elements in the grid initialized on edit mode because they are bound in my markup. Below is the code I am trying to use to check some items in the RadComboBox (OnEditOrInsertMode handles RadGrid.OnItemCreated, getFormFactorIds is a function that returns a list of ids to be checked.):

01.protected void OnEditOrInsertMode(object sender, GridItemEventArgs e)
02.{
03.    // Initalizes the RadComboBoxFormFactor combobox like all the other controls in the form.
04.    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
05.    {
06.        GridEditableItem item = (GridEditableItem) e.Item;
07.        RadComboBox formFactorComboBox = (RadComboBox) e.Item.FindControl("RadComboBoxFormFactor");
08.        List<int> formFactorIds = (List<int>) getFormFactorIds((int) ((GridEditableItem)e.Item).GetDataKeyValue("CID"));
09. 
10.        formFactorComboBox.DataBind();
11.        foreach (RadComboBoxItem rcbItem in formFactorComboBox.Items)
12.        {
13.            rcbItem.Checked = formFactorIds.Contains(int.Parse(rcbItem.Value));
14.        }
15.        formFactorComboBox.DataBind();
16.    }
17.}


But, this seems to have no effect when I verify that a particular item has values marked in the multiple select combobox, and step through the code in the debugger and watch the 'Checked' values be set to 'true'.

What is causing the 'Checked' values to be set back to false?
Am I setting the 'Checked' values in the correct handler?

Thanks

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 24 Feb 2015, 01:35 PM
Hello Michael,

I've created a sample RadGrid web site to demonstrate how you can achieve this requirement. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or