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

Griddropdown issue in editmode

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 06 Apr 2012, 04:57 PM
I have my grid automatically kicked into edit mode for all rows when it loads. I have a dropdown list that is populated successfully for the 1st row but the subsequent rows aren't displayed properly, it only states the name of the object for each value in the dropdown list, please see this image for what i mean. Here is my code for populating the dropdowns:

if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            //for edit mode
            string selectedCommentIndex = "";
            GridEditableItem item = e.Item as GridEditableItem;
            GridEditManager editMan = item.EditManager;
 
            GridDropDownListColumnEditor commenteditor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("Action"));
            GridDropDownColumn testing = e.Item.OwnerTableView.Columns.FindByUniqueName("Action") as GridDropDownColumn;
 
             
                var comments = (from c in db.Entered_Comments
                                where c.type_id == 2
                                select c).ToList();
 
                 
 
                commenteditor.DataSource = comments;
                commenteditor.DataTextField = "description";
                commenteditor.DataValueField = "comment_id";
                commenteditor.DataBind();
                commenteditor.Visible = true;
                commenteditor.ComboBoxControl.SelectedValue = selectedCommentIndex;
                commenteditor.DropDownListControl.SelectedValue = selectedCommentIndex;
                commenteditor.ComboBoxControl.AllowCustomText = true;
                commenteditor.ComboBoxControl.EmptyMessage = Resources.DataEntry_ResultEntryByTestPracticeResource.commenteditorComboBoxControlEmptyMessage;
                commenteditor.ComboBoxControl.Filter = RadComboBoxFilter.Contains;
                commenteditor.ComboBoxControl.CssClass = "rcbDropDown";
            
}



1 Answer, 1 is accepted

Sort by
0
Johny
Top achievements
Rank 1
answered on 11 Apr 2012, 03:58 PM
Hi

I had similar problems before and telerik send me this link:

http://www.telerik.com/help/aspnet-ajax/grid-customize-configure-griddropdowncolumn.html

My problem was that i had wrong relation between dataFiels and ListValueFiled. telrik says:

"Ensure that the fields specified through the DataField/ListValueField properties are of the same data type and the entries have a precise match, otherwise you will get merely the first item from the list displayed in non-editable mode. This can also happen if you have not configured properly the GridDropDownColumn, e.g. the relations between the fields specified through the DataField/ListValueField properties. "

Thanks
Johny
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Johny
Top achievements
Rank 1
Share this question
or