B
bill yeager
I'm using the customvalidator in my web page. I get the
following error when I try to run the web page:
Unable to find control id 'lstRider' referenced by
the 'ControlToValidate' property of 'cvRiders'.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
stack trace for more information about the error and where
it originated in the code.
Exception Details: System.Web.HttpException: Unable to
find control id 'lstRider' referenced by
the 'ControlToValidate' property of 'cvRiders'
Here is part of my HTML that is of concern:
<asp:TemplateColumn HeaderText="Riders">
<ItemTemplate>
<asp:listbox AutoPostBack="False"
BackColor="#ffffff" id="lstRider" runat="server" Rows="1"
DataSource="<%# DsRider1 %>" Enabled="True"
SelectionMode="Multiple" DataTextField="UserName"
DataValueField="UserID" />
</asp:listbox>
</ItemTemplate>
</asp:TemplateColumn>
</asp:datagrid><asp:customvalidator id="cvRiders" style="Z-
INDEX: 104; LEFT: 136px; POSITION: absolute; TOP: 88px"
runat="server"
display="Static"
OnServerValidate="lstRiderValidation" ErrorMessage="Riders
has a maximum selection of 2"
ControlToValidate="lstRider"></asp:customvalidator>
This is what I have in my code-behind:
Sub lstRiderValidation(ByVal source As Object, ByVal
arguments As ServerValidateEventArgs) Handles
cvRiders.ServerValidate
Dim strSelectionArray() As String =
arguments.Value.Split(",")
If strSelectionArray(2).Length > 0 Then 'Max 2
selections
arguments.IsValid = False
Else
arguments.IsValid = True
End If
End Sub
How can I get the customvalidator to recognize my control?
I know it's probably because the control is an
itemtemplate...
following error when I try to run the web page:
Unable to find control id 'lstRider' referenced by
the 'ControlToValidate' property of 'cvRiders'.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
stack trace for more information about the error and where
it originated in the code.
Exception Details: System.Web.HttpException: Unable to
find control id 'lstRider' referenced by
the 'ControlToValidate' property of 'cvRiders'
Here is part of my HTML that is of concern:
<asp:TemplateColumn HeaderText="Riders">
<ItemTemplate>
<asp:listbox AutoPostBack="False"
BackColor="#ffffff" id="lstRider" runat="server" Rows="1"
DataSource="<%# DsRider1 %>" Enabled="True"
SelectionMode="Multiple" DataTextField="UserName"
DataValueField="UserID" />
</asp:listbox>
</ItemTemplate>
</asp:TemplateColumn>
</asp:datagrid><asp:customvalidator id="cvRiders" style="Z-
INDEX: 104; LEFT: 136px; POSITION: absolute; TOP: 88px"
runat="server"
display="Static"
OnServerValidate="lstRiderValidation" ErrorMessage="Riders
has a maximum selection of 2"
ControlToValidate="lstRider"></asp:customvalidator>
This is what I have in my code-behind:
Sub lstRiderValidation(ByVal source As Object, ByVal
arguments As ServerValidateEventArgs) Handles
cvRiders.ServerValidate
Dim strSelectionArray() As String =
arguments.Value.Split(",")
If strSelectionArray(2).Length > 0 Then 'Max 2
selections
arguments.IsValid = False
Else
arguments.IsValid = True
End If
End Sub
How can I get the customvalidator to recognize my control?
I know it's probably because the control is an
itemtemplate...