I'm using ASP.NET AJAX Q1 2012 SP1. I have a RadGrid with a GridDropDownColumn. The RadGrid is populated on server side from the RadGrid's NeedDataSource event. Everything is working except the expected DataField value is blank when the grid is in a non edit mode. To test I even added a GridBoundColumn with the same DataField name to show that it does have a value.
Server side programming.
Here is a screenshot of the web page.
ScreenShot
The only way I can think of getting this to work is to set the cells text to the data value within the ItemDataBound event. Something like this.
Is this a known bug or am I doing something wrong?
Thanks,
Warren
<
telerik:RadGrid
ID
=
"rgDepartment"
runat
=
"server"
Skin
=
"Office2007"
AutoGenerateColumns
=
"False"
AutoGenerateDeleteColumn
=
"True"
CellSpacing
=
"0"
GridLines
=
"None"
AllowMultiRowEdit
=
"true"
>
<
MasterTableView
DataKeyNames
=
"OrgDepartmentId"
AutoGenerateColumns
=
"false"
EditMode
=
"InPlace"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Dept"
UniqueName
=
"Name"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDropDownColumn
ListTextField
=
"Name"
ListValueField
=
"DepartmentId"
DataField
=
"Name"
HeaderText
=
"Department"
DropDownControlType
=
"DropDownList"
UniqueName
=
"OrgDept"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridBoundColumn
DataField
=
"DepartmentId"
HeaderText
=
"Speech Rec Object Id"
MaxLength
=
"255"
UniqueName
=
"DepartmentId"
>
</
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Server side programming.
Protected
Sub
rgDepartment_ItemDataBound(sender
As
Object
, e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
rgDepartment.ItemDataBound
If
(
TypeOf
e.Item
Is
GridEditableItem
AndAlso
CType
(e.Item, GridEditableItem).IsInEditMode)
Then
Dim
editedItem
As
GridEditableItem =
CType
(e.Item, GridEditableItem)
' Hides the Update button for each edit form
editedItem(
"EditCommandColumn"
).Controls(0).Visible =
False
' Apply the text box style
CType
(editedItem(
"DepartmentId"
).Controls(0), TextBox).CssClass =
"TextBoxStyle"
' Populate drop down
Dim
editMan
As
GridEditManager = editedItem.EditManager
Dim
editor
As
GridDropDownColumnEditor =
CType
(editMan.GetColumnEditor(
"OrgDept"
), GridDropDownColumnEditor)
editor.DataSource = GetOrganizationDepartmentData()
editor.DataBind()
If
e.Item.OwnerTableView.IsItemInserted =
False
AndAlso
e.Item.DataItem(
"OrgDepartmentId"
) IsNot
Nothing
AndAlso
e.Item.DataItem(
"OrgDepartmentId"
) > 0
Then
editor.SelectedValue = e.Item.DataItem(
"OrgDepartmentId"
).ToString()
End
If
End
If
End
Sub
Protected
Sub
rgDepartment_NeedDataSource(sender
As
Object
, e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
rgDepartment.NeedDataSource
rgDepartment.DataSource = GetDeptData()
' Get Dataset
End
Sub
Here is a screenshot of the web page.
ScreenShot
The only way I can think of getting this to work is to set the cells text to the data value within the ItemDataBound event. Something like this.
If
(
TypeOf
e.Item
Is
GridDataItem
AndAlso
e.Item.IsInEditMode =
False
)
Then
Dim
dataItem
As
GridDataItem =
CType
(e.Item, GridDataItem)
dataItem(
"OrgDept"
).Text = e.Item.DataItem(
"Name"
)
End
If
Is this a known bug or am I doing something wrong?
Thanks,
Warren