I am attempting to load values in a RadComboBox inside a RadGrid and I am getting the following error -
"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control"
Here is the markup for the grid
and here is the code that is binding the combo box
I had read in other threads about removing the DataBind() from the above code, but all that does is allow the load of the "Select A Status" item and none of the database items.
Thanks!
"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control"
Here is the markup for the grid
<
telerik:RadGrid
runat
=
"server"
ID
=
"rgrdClaimantStatus"
AutoGenerateColumns
=
"False"
Skin
=
"Windows7"
OnInt
=
"InitializeGrid"
Style
=
"margin-top: 0px"
OnNeedDataSource
=
"rgrdClaimantStatus_NeedDataSource"
OnUpdateCommand
=
"rgrdClaimantStatus_UpdateCommand"
OnInsertCommand
=
"rgrdClaimantStatus_InsertCommand"
OnDeleteCommand
=
"rgrdClaimantStatus_DeleteCommand"
OnItemCommand
=
"rgrdClaimantStatus_ItemCommand"
OnItemDataBound
=
"rgrdClaimantStatus_ItemDataBound"
OnPreRender
=
"rgrdClaimantStatus_PreRender"
OnItemCreated
=
"rgrdClaimantStatus_ItemCreated"
TabIndex
=
"21"
>
<
MasterTableView
commanditemdisplay
=
"Top"
EditMode
=
"InPlace"
ShowHeadersWhenNoRecords
=
"True"
>
<
Columns
>
<
telerik:GridButtonColumn
CommandName
=
"Delete"
ButtonType
=
"ImageButton"
ImageUrl
=
"~/PPSPortal/images/Cancel.gif"
UniqueName
=
"DeleteColumn"
ShowInEditForm
=
"True"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"StatusDesc"
DataField
=
"StatusDesc"
HeaderText
=
"Status"
FooterStyle-Font-Bold
=
"true"
FooterStyle-Wrap
=
"false"
ItemStyle-Wrap
=
"false"
>
<
ItemTemplate
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"rcbClaimantStatusCode"
Width
=
"100"
Text='<%# Bind("StatusDesc") %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"DateFrom"
DataField
=
"DateFrom"
HeaderText
=
"Date From"
FooterStyle-Font-Bold
=
"true"
FooterStyle-Wrap
=
"false"
ItemStyle-Wrap
=
"false"
>
<
ItemTemplate
>
<
telerik:RadDatePicker
runat
=
"server"
ID
=
"rdpClaimantStatusStartDate"
width
=
"150"
DbSelectedDate='<%# Bind("DateFrom") %>'>
<
Calendar
UseRowHeadersAsSelectors
=
"False"
UseColumnHeadersAsSelectors
=
"False"
ViewSelectorText
=
"x"
></
Calendar
>
<
DateInput
DisplayDateFormat
=
"M/d/yyyy"
DateFormat
=
"M/d/yyyy"
TabIndex
=
"2"
/>
<
DatePopupButton
ImageUrl
=
""
HoverImageUrl
=
""
TabIndex
=
"2"
></
DatePopupButton
>
</
telerik:RadDatePicker
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"DateTo"
DataField
=
"DateTo"
HeaderText
=
"Date To"
FooterStyle-Font-Bold
=
"true"
FooterStyle-Wrap
=
"false"
ItemStyle-Wrap
=
"false"
>
<
ItemTemplate
>
<
telerik:RadDatePicker
runat
=
"server"
ID
=
"rdpClaimantEndDate"
width
=
"150"
onkeydown
=
"ClaimantStatusEndDateKeyDown(this, event)"
DbSelectedDate='<%# Bind("DateTo") %>'>
<
Calendar
UseRowHeadersAsSelectors
=
"False"
UseColumnHeadersAsSelectors
=
"False"
ViewSelectorText
=
"x"
></
Calendar
>
<
DateInput
DisplayDateFormat
=
"M/d/yyyy"
DateFormat
=
"M/d/yyyy"
TabIndex
=
"2"
/>
<
DatePopupButton
ImageUrl
=
""
HoverImageUrl
=
""
TabIndex
=
"2"
></
DatePopupButton
>
</
telerik:RadDatePicker
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"DateCreated"
DataField
=
"DateCreated"
HeaderText
=
"Date Created"
FooterStyle-Font-Bold
=
"true"
FooterStyle-Wrap
=
"false"
ItemStyle-Wrap
=
"false"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"lblClaimantDateCreated"
Width
=
"150"
Text='<%# Bind("DateCreated") %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"DateEdited"
DataField
=
"DateEdited"
HeaderText
=
"Date Edited"
FooterStyle-Font-Bold
=
"true"
FooterStyle-Wrap
=
"false"
ItemStyle-Wrap
=
"false"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"lblClaimantDateEdited"
Width
=
"150"
Text='<%# Bind("DateEdited") %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"ModifiedBy"
DataField
=
"ModifiedBy"
HeaderText
=
"Modified By"
FooterStyle-Font-Bold
=
"true"
FooterStyle-Wrap
=
"false"
ItemStyle-Wrap
=
"false"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"lblClaimantModifiedBy"
Width
=
"150"
Text='<%# Bind("ModifiedBy") %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
EnableDragToSelectRows
=
"false"
/>
<
DataBinding
EnableCaching
=
"True"
/>
<
ClientEvents
OnKeyPress
=
"KeyPressed"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
and here is the code that is binding the combo box
protected
void
rgrdClaimantStatus_ItemDataBound(
object
source, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
//SetEditModeColumnWidths(e.Item as GridDataItem);
RadComboBox status = ((e.Item
as
GridDataItem)[
"StatusDesc"
].FindControl(
"rcbClaimantStatusCode"
)
as
RadComboBox);
LoadClaimantStatusList(status, Convert.ToInt32((GetSelectedCompany())));
}
}
protected
void
LoadClaimantStatusList(RadComboBox rddlStatus,
int
companyId)
{
ReferenceProcess rc =
new
ReferenceProcess();
Dictionary<
int
,
string
> statusList = rc.GetClaimantStatusList(CentralDBConnString, companyId);
rddlStatus.DataSource = statusList;
rddlStatus.DataTextField =
"Value"
;
rddlStatus.DataValueField =
"Key"
;
rddlStatus.DataBind();
rddlStatus.Items.Insert(0,
new
RadComboBoxItem(
"Select a status"
,
string
.Empty));
}
I had read in other threads about removing the DataBind() from the above code, but all that does is allow the load of the "Select A Status" item and none of the database items.
Thanks!