Hi,
I've got a RadListBox linked with a RequiredFieldValidator from ASP.NET and it's possible this RadListBox loads with preselected items. So, I open the corresponding page and reckon I haven't got to make a change in the selection of the RadListBox and just press my validation button. Unfortunately, I'm getting an error from the validator that I haven't selected a thing in my RadListBox, while there are some items preselected.
My RadListBox looks like:
The RadListBox loads like:
And the validator:
As you can see the DataBound event checks the preselected items as it should, but if I click my validation button I get the error from my validator that I haven't checked any items in the RadListBox.
What am I doing wrong?
Thanks in advance.
Regards,
Datamex
I've got a RadListBox linked with a RequiredFieldValidator from ASP.NET and it's possible this RadListBox loads with preselected items. So, I open the corresponding page and reckon I haven't got to make a change in the selection of the RadListBox and just press my validation button. Unfortunately, I'm getting an error from the validator that I haven't selected a thing in my RadListBox, while there are some items preselected.
My RadListBox looks like:
<
telerik:RadListBox
ID
=
"DepartmentsListBox"
runat
=
"server"
CheckBoxes
=
"true"
SelectionMode
=
"Multiple"
Width
=
"95%"
DataSourceID
=
"DepartmentsDataSource"
DataTextField
=
"Name"
DataValueField
=
"DepartmentID"
OnDataBound
=
"DepartmentsListBox_DataBound"
>
</
telerik:RadListBox
>
<
asp:ObjectDataSource
ID
=
"DepartmentsDataSource"
runat
=
"server"
SelectMethod
=
"GetDepartments"
TypeName
=
"Datamex.Projects.Nebulus.BusinessLogics.Departments"
>
</
asp:ObjectDataSource
>
The RadListBox loads like:
protected void DepartmentsListBox_DataBound(object sender, EventArgs e)
{
foreach (RadListBoxItem item in DepartmentsListBox.Items)
{
item.Checked = hc.DepartmentHourCategoryLinks.Any(l => l.DepartmentID == Guid.Parse(item.Value));
}
}
And the validator:
<
asp:RequiredFieldValidator
ID
=
"DepartmentsValidator"
runat
=
"server"
ControlToValidate
=
"DepartmentsListBox"
ValidationGroup
=
"Save"
CssClass
=
"Validator"
Text
=
"*"
ErrorMessage="<%$ Resources:Resources, DepartmentsRequiredMessage %>" />
As you can see the DataBound event checks the preselected items as it should, but if I click my validation button I get the error from my validator that I haven't checked any items in the RadListBox.
What am I doing wrong?
Thanks in advance.
Regards,
Datamex