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

Griddropdown column not dispalaying value in read only mode

3 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 10 Nov 2011, 10:49 AM
Guys, i have defined a griddropdowncolumn but for some reason it is not displaying the bound value. When it edit mode, i populate the dropdown with no issues. Here is my column definition in the front end:

<telerik:GridDropDownColumn ListTextField="LotDetail.LotNumber" ListValueField="LotDetail.LotNumber" DataType="System.String"
            FilterControlAltText="Lot Number" HeaderText="Lot Number"
            SortExpression="LotDetail.LotNumber" UniqueName="LotNo" ReadOnly="true">
        </telerik:GridDropDownColumn>

If anyone could shed any light on this it would be great. My Telerik.Web.UI.dll version is 2011.2.915.40.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Nov 2011, 11:40 AM
Hello Michael,

I cannot find any DataSource associated with the dropdown in browser mode. In browser mode, GridDropDownColumn looks and behaves like a standard GridBoundColumn. When in edit mode, however, it displays a drop-down control for each edited cell in the column. Also check the following help documentation.
Column Types.

-Shinu
0
Michael
Top achievements
Rank 1
answered on 10 Nov 2011, 12:02 PM
Shinu, my data is populated via the needdatasource method. All other fields are populated. If i turn the column into a GridBoundColumn it displays the value. Do i need extra code in the code behind to populate the drop down in read only mode? I looked at the examples on the telerik site and the dropdown are populated in read only mode without any extra code in the code behind.

Here is my code for populating in edit mode:

if (e.Item is GridEditableItem && e.Item.IsInEditMode)
       {
 
           GridEditableItem editedItem = e.Item as GridDataItem;
           GridEditManager editMan = editedItem.EditManager;
           GridDropDownListColumnEditor LotNoEditor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("LotNo"));
           LotManager lotManager = new LotManager();
           LotNoEditor.DataSource = lotManager.GetLot((Session["User"] as User).partcipant.PartNumber);
           LotNoEditor.DataTextField = "LotNumber";
           LotNoEditor.DataValueField = "LotNumber";
           LotNoEditor.DataBind();
           LotNoEditor.ComboBoxControl.AllowCustomText = false;
           LotNoEditor.ComboBoxControl.EmptyMessage = "Choose Lot from list";
           LotNoEditor.ComboBoxControl.Filter = RadComboBoxFilter.Contains;
           //lotManager.GetLot(Partnumber);
       }
0
Michael
Top achievements
Rank 1
answered on 10 Nov 2011, 01:09 PM
I finally got this sorted, don't know if this is the correct way to do it but it works for me(
in itemdatabound:

if (e.Item is GridDataItem)
        {
            GridDataItem dataItem = e.Item as GridDataItem;
            if (e.Item.DataItem != null && e.Item.DataItem is FixedMeanAndSD)
            {
                FixedMeanAndSD row = (FixedMeanAndSD)e.Item.DataItem;
                dataItem["LotNo"].Text = row.LotDetail.LotNumber;
            }
 
             
 
        }
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Michael
Top achievements
Rank 1
Share this question
or