|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CustomValidator points to wrong controlRepeater 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:DropDownList 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:DropDownList> </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:Panel ID="mapSelectPanel" runat="server"> <br /> <asp:Localize ID="Localize13" runat="server" Text='<%$ Resources:Prompt, Select %>' /> <asp:TextBox ID="mapSelect" runat="server" Columns="50" Text='<%#Eval("Select")%>'></asp:TextBox> <asp:DropDownList ID="mapSelectDatasource" runat="server" /> <asp:CustomValidator ID="CustomValidator2" runat="server" OnServerValidate="ValidateMapDatasource" ControlToValidate="mapSelectDatasource" Text="Please select a datasource." /> </asp:Panel> </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 Hi David,
I have done some test, but wasn't able to reproduce the issue you mentioned. First, I don't think the FindControl("mapType") is returning the wrong DropDownList, can you verify that, for example: change the found DropDownList's SelectedIndex in the validate event. During my test, if I bound the repeater in every postback, the state of the DropDownList will be lost and the SelectedIndex will always be 0. Could you please post the complete webform so that I can test that? Thanks. Sincerely, Walter Wang (waw***@online.microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. If you are using Outlook Express, please make sure you clear the check box "Tools/Options/Read: Get 300 headers at a time" to see your reply promptly. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. I swear this was working wrong yesterday - but it is working fine now. If I
get the problem again I will get as much info as I can from it. -- Show quoteHide quotethanks - dave david_at_windward_dot_net http://www.windwardreports.com Cubicle Wars - http://www.windwardreports.com/film.htm "Walter Wang [MSFT]" wrote: > Hi David, > > I have done some test, but wasn't able to reproduce the issue you mentioned. > > First, I don't think the FindControl("mapType") is returning the wrong > DropDownList, can you verify that, for example: change the found > DropDownList's SelectedIndex in the validate event. > > During my test, if I bound the repeater in every postback, the state of the > DropDownList will be lost and the SelectedIndex will always be 0. > > Could you please post the complete webform so that I can test that? Thanks. > > Sincerely, > Walter Wang (waw***@online.microsoft.com, remove 'online.') > Microsoft Online Community Support > > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. If you are using Outlook Express, please make sure you clear the > check box "Tools/Options/Read: Get 300 headers at a time" to see your reply > promptly. > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no rights. > > Hi David,
Please feel free to let me know if the problem occurrs again. Have a nice weekend! Regards, Walter Wang (waw***@online.microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Menu Control Questions
HyperLinkField and OnRowDataBound ControlCollection.Remove bug Solution - Treeview Site Navigation without ShowExpandCollapse Radiobuttonlist (a custom control) selectedindexchanged event not firing in User Control Redirecting to another page operations on string DropDownList Refuses To Show New SelectedValue how to show dialogbox when click on datagrid template column? Data Grid Printing |
|||||||||||||||||||||||