Hi,
I am trying to bind a dropdownlist in the itemdataBound event, but when I enter edit mode I am getting the error:
"Specified argument was out of the range of valid values. Parameter name: index"
for the line:
"Dim editor As GridDropDownListColumnEditor = CType(editMan.GetColumnEditor("Band"), GridDropDownListColumnEditor)"
I was referring to this to bind the dropdown: http://www.telerik.com/help/aspnet-ajax/grid-customize-configure-griddropdowncolumn.html
Any ideas why I am getting this error?
My code is below:
RadGrid1_ItemDataBound
aspx
I am trying to bind a dropdownlist in the itemdataBound event, but when I enter edit mode I am getting the error:
"Specified argument was out of the range of valid values. Parameter name: index"
for the line:
"Dim editor As GridDropDownListColumnEditor = CType(editMan.GetColumnEditor("Band"), GridDropDownListColumnEditor)"
I was referring to this to bind the dropdown: http://www.telerik.com/help/aspnet-ajax/grid-customize-configure-griddropdowncolumn.html
Any ideas why I am getting this error?
My code is below:
RadGrid1_ItemDataBound
Private Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
If TypeOf e.Item Is GridDataItem Then
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
Dim row As DataRowView = DirectCast(e.Item.DataItem, DataRowView)
item("Band").Text = row("Band").ToString()
item("capoptioname").Text = row("capoptioname").ToString()
End If
If (TypeOf e.Item Is GridEditableItem AndAlso CType(e.Item, GridEditableItem).IsInEditMode) Then
Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim editMan As GridEditManager = editedItem.EditManager
Dim editor As GridDropDownListColumnEditor = CType(editMan.GetColumnEditor("Band"), GridDropDownListColumnEditor)
Dim ddlBand As DropDownList = editor.DropDownListControl
Dim ProductBus As New Product
Dim bands As Entities.Product.callbandsDataTable
bands = ProductBus.GetCallBandsList
ddlBand.DataSource = bands
ddlBand.DataTextField = "description"
ddlBand.DataValueField = "value"
ddlBand.DataBind()
End If
End Sub
aspx
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
PagerStyle-AlwaysVisible
=
"true"
AllowPaging
=
"True"
AllowSorting
=
"True"
pagesize
=
"25"
pagerposition
=
"bottom"
GridLines
=
"None"
Width
=
"99.9%"
EnableEmbeddedSkins
=
"False"
AllowMultiRowEdit
=
"True"
OnSortCommand
=
"RadGrid1_SortCommand"
ShowStatusBar
=
"True"
Skin
=
"p3"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
AllowFilteringByColumn
=
"True"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
Culture
=
"en-GB"
>
<
MasterTableView
EditMode
=
"inplace"
AllowMultiColumnSorting
=
"true"
DataKeyNames
=
"id"
GridLines
=
"Both"
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
/>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
Visible
=
"True"
> </
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
Visible
=
"True"
> </
ExpandCollapseColumn
>
<
CommandItemTemplate
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridEditCommandColumn
HeaderStyle-Width
=
"4%"
ButtonType
=
"ImageButton"
EditImageUrl
=
"/images/edit.png"
/>
<
telerik:GridBoundColumn
UniqueName
=
"id"
DataField
=
"id"
HeaderText
=
"id"
ReadOnly
=
"True"
HeaderStyle-Width
=
"1%"
Display
=
"False"
> </
telerik:GridBoundColumn
>
<
telerik:GridDropDownColumn
DataField
=
"Band"
HeaderText
=
"Band"
UniqueName
=
"Band"
ColumnEditorID
=
"GridDropDownListColumnEditor1"
HeaderStyle-Width
=
"10%"
ListTextField
=
"description"
ListValueField
=
"value"
EnableEmptyListItem
=
"true"
EmptyListItemValue
=
"0"
EmptyListItemText
=
"please select"
FilterControlAltText
=
"Filter callband column"
DropDownControlType
=
"RadComboBox"
> </
telerik:GridDropDownColumn
>
</
Columns
>
<
PagerStyle
AlwaysVisible
=
"True"
/>
</
MasterTableView
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
ScrollHeight
=
""
SaveScrollPosition
=
"True"
></
Scrolling
>
</
ClientSettings
>
<
SortingSettings
EnableSkinSortStyles
=
"false"
></
SortingSettings
>
<
PagerStyle
Mode
=
"NumericPages"
/>
</
telerik:RadGrid
>
<
telerik:GridDropDownListColumnEditor
ID
=
"GridDropDownListColumnEditor1"
runat
=
"server"
DropDownStyle-Width
=
"200px"
> </
telerik:GridDropDownListColumnEditor
>