D
David Thielen
There is a lot of code below so I will try to explain first. I have a
Repeater and in the Repeater I have a Panel. In the Panel I have a
CustomValidator that needs to work with the value of a control that is
outside the Panel, but inside the Repeater.
What appears to be happening is that if the Panel is visible, it then calls
the CustomValidator - but for the CustomValidator in a different row - that
is hidden.
Here is my code:
protected void ValidateMapDatasource(object sender, ServerValidateEventArgs
args) {
CustomValidator vldtr = (CustomValidator)sender;
DropDownList lst = (DropDownList)vldtr.Parent.Parent.FindControl("mapType");
if (lst.SelectedIndex != 4) {
args.IsValid = true;
return;
}
// should come to here as SelectedIndex == 4 if the Panel is visible - but
returns above because it gets the lst for the next row.
Here is the aspx:
<asp:Repeater ID="mapRows" runat="server"
OnItemDataBound="MapDataBind">
<HeaderTemplate>
<table width="100%">
<tr>
<th>
<asp:Localize ID="Localize9" runat="server" Text='required'
/></th>
<th>
<asp:Localize ID="Localize10" runat="server" Text='<%$
Resources:Header, VarName %>' /></th>
<th>
<asp:Localize ID="Localize11" runat="server" Text='type' /></th>
<th>
<asp:Localize ID="Localize12" runat="server" Text='description'
/></th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="mapRequired" runat="server"
Checked='<%#Eval("Required")%>' /></td>
<td>
<asp:Label ID="mapName" runat="server"
Text='<%#Eval("Name")%>'></asp:Label>
</td>
<td>
<asp
ropDownList ID="mapType" runat="server"
SelectedIndex='<%#Eval("Type")%>'>
<asp:ListItem Value="0" Text='<%$ Resources:Value, Currency %>' />
<asp:ListItem Value="1" Text='<%$ Resources:Value, Date %>' />
<asp:ListItem Value="2" Text='<%$ Resources:Value, Integer %>' />
<asp:ListItem Value="3" Text='<%$ Resources:Value, Number %>' />
<asp:ListItem Value="4" Text='<%$ Resources:Value, Select %>' />
<asp:ListItem Value="5" Text='<%$ Resources:Value, Text %>' />
</asp
ropDownList>
</td>
<td>
<asp:TextBox ID="mapDescription" runat="server" Columns="60"
Rows="4" Height="72px"
TextMode="MultiLine" />
<aspWindward:HelpLink ID="HelpLink6" runat="server"
File="template3" Bookmark="mapvalues" />
<asp
anel ID="mapSelectPanel" runat="server">
<br />
<asp:Localize ID="Localize13" runat="server" Text='<%$
Resources
rompt, Select %>' />
<asp:TextBox ID="mapSelect" runat="server" Columns="50"
Text='<%#Eval("Select")%>'></asp:TextBox>
<asp
ropDownList ID="mapSelectDatasource" runat="server" />
<asp:CustomValidator ID="CustomValidator2" runat="server"
OnServerValidate="ValidateMapDatasource"
ControlToValidate="mapSelectDatasource" Text="Please select a
datasource." />
</asp
anel>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Any ideas?
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
Repeater and in the Repeater I have a Panel. In the Panel I have a
CustomValidator that needs to work with the value of a control that is
outside the Panel, but inside the Repeater.
What appears to be happening is that if the Panel is visible, it then calls
the CustomValidator - but for the CustomValidator in a different row - that
is hidden.
Here is my code:
protected void ValidateMapDatasource(object sender, ServerValidateEventArgs
args) {
CustomValidator vldtr = (CustomValidator)sender;
DropDownList lst = (DropDownList)vldtr.Parent.Parent.FindControl("mapType");
if (lst.SelectedIndex != 4) {
args.IsValid = true;
return;
}
// should come to here as SelectedIndex == 4 if the Panel is visible - but
returns above because it gets the lst for the next row.
Here is the aspx:
<asp:Repeater ID="mapRows" runat="server"
OnItemDataBound="MapDataBind">
<HeaderTemplate>
<table width="100%">
<tr>
<th>
<asp:Localize ID="Localize9" runat="server" Text='required'
/></th>
<th>
<asp:Localize ID="Localize10" runat="server" Text='<%$
Resources:Header, VarName %>' /></th>
<th>
<asp:Localize ID="Localize11" runat="server" Text='type' /></th>
<th>
<asp:Localize ID="Localize12" runat="server" Text='description'
/></th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="mapRequired" runat="server"
Checked='<%#Eval("Required")%>' /></td>
<td>
<asp:Label ID="mapName" runat="server"
Text='<%#Eval("Name")%>'></asp:Label>
</td>
<td>
<asp
SelectedIndex='<%#Eval("Type")%>'>
<asp:ListItem Value="0" Text='<%$ Resources:Value, Currency %>' />
<asp:ListItem Value="1" Text='<%$ Resources:Value, Date %>' />
<asp:ListItem Value="2" Text='<%$ Resources:Value, Integer %>' />
<asp:ListItem Value="3" Text='<%$ Resources:Value, Number %>' />
<asp:ListItem Value="4" Text='<%$ Resources:Value, Select %>' />
<asp:ListItem Value="5" Text='<%$ Resources:Value, Text %>' />
</asp
</td>
<td>
<asp:TextBox ID="mapDescription" runat="server" Columns="60"
Rows="4" Height="72px"
TextMode="MultiLine" />
<aspWindward:HelpLink ID="HelpLink6" runat="server"
File="template3" Bookmark="mapvalues" />
<asp
<br />
<asp:Localize ID="Localize13" runat="server" Text='<%$
Resources
<asp:TextBox ID="mapSelect" runat="server" Columns="50"
Text='<%#Eval("Select")%>'></asp:TextBox>
<asp
<asp:CustomValidator ID="CustomValidator2" runat="server"
OnServerValidate="ValidateMapDatasource"
ControlToValidate="mapSelectDatasource" Text="Please select a
datasource." />
</asp
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Any ideas?
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm