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

The GridDropDownColumn is not bound under view mode

3 Answers 106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jin
Top achievements
Rank 1
Jin asked on 14 Aug 2012, 08:34 AM
I have a RadGrid with GridDropDownColumn. Then I set the DataField attribute for the dropdownlist. When loading the GridView, the column display null. I don't know why it will be null.

 <telerik:GridDropDownColumn DataField="PV_TYPE" ListTextField="PV_TYPE" UniqueName="PvType" HeaderText="PV Type">
                            </telerik:GridDropDownColumn>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Aug 2012, 08:59 AM
Hi Jin,

When 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. In order to bind this column type, you should set the DataSourceID property to the ID of a data source control.
aspx:
<telerik:GridDropDownColumn DataField="EmployeeID" ListTextField="EmployeeID" ListValueField="EmployeeID" DataSourceID="SqlDataSource1" ></telerik:GridDropDownColumn>

Thanks,
Shinu.
0
Jin
Top achievements
Rank 1
answered on 14 Aug 2012, 09:07 AM
Thanks for your response. In fact, my problem is the  GridDropDownColumn don't show a value in View mode. As my understanding, once the DataFiled is set, it should bind a value to the GridDropDownColumn as a lable in view mode.

0
Shinu
Top achievements
Rank 2
answered on 16 Aug 2012, 07:36 AM
Hi,

In order to make the GridDropDownColumn to show value in view mode, you should set DataSource as shown below.
aspx:
<telerik:GridDropDownColumn DataField="EmployeeID"  DropDownControlType="RadComboBox" ListTextField="EmployeeID" ListValueField="EmployeeID" DataSourceID="SqlDataSource1" ></telerik:GridDropDownColumn>
Also you can bind the column in edit mode as shown below.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
 if (e.Item is GridEditableItem & e.Item.IsInEditMode)
 {
   GridEditableItem EditItem = (GridEditableItem)e.Item;
   RadComboBox combo = (RadComboBox)EditItem["dropdown"].Controls[0];
   combo.DataTextField = "EmployeeID";
   combo.DataValueField = "EmployeeID";
   combo.DataSourceID = "SqlDataSource1";
 }
}

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