ValidationSummary doesn't show Errors

徘徊边缘 提交于 2019-12-13 06:24:14

问题


I have a problem with my gridview which won't show the ValidationSummary-errors anymore. The Headertext of the ValidationSummary does show up as well as the * which I set to appear whenever the ExpressionValidation fires.

I'm quite sure it worked before, but I don't know why it doesn't anymore. At first I thought it might have something to do with the other GridViews on the page as I have like 5 different GridView in different TabPanels, but I already made one validationgroup per GridView.

Markup:

<asp:UpdatePanel runat="server" UpdateMode="Always">
    <ContentTemplate>
       <asp:GridView ID="gvBBG" runat="server" AutoGenerateColumns="false" DataKeyNames="ID" SkinID="gvWithoutWidth">
         <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                   <asp:ImageButton runat="server" ImageUrl="~/Images/GridView/gv_edit.png" CommandName="Edit"/>
                </ItemTemplate>
                <EditItemTemplate>
                   <asp:ImageButton runat="server" ImageUrl="~/Images/GridView/gv_cancel.png" CommandName="Cancel" CausesValidation="false"/>
                   <asp:ImageButton Id="ibUpdate" runat="server" ImageUrl="~/Images/GridView/gv_update.png" CommandName="Update"  CausesValidation="true"
                        ValidationGroup="UpdateBBG" Enabled="true" OnClientClick="return confirm('Datensatz einspielen/aktualisieren?')"/>
                </EditItemTemplate>
           </asp:TemplateField>
           <asp:TemplateField HeaderText="KV West" HeaderStyle-HorizontalAlign="Left">
               <EditItemTemplate>
                    <asp:TextBox ID="tbKVWest" runat="server" Text='<%# Bind("KVWestFormatted") %>' ValidationGroup="UpdateBBG" Width="50px" Height="15px"></asp:TextBox>
                     <asp:RequiredFieldValidator ID="rfvKVWest" ValidationGroup="UpdateBBG" runat="server"
                           ControlToValidate="tbKVWest" ErrorMessage="Bitte KVWest als Summe angeben"
                           SetFocusOnError="true">*</asp:RequiredFieldValidator> 
                      <asp:RegularExpressionValidator ID="revKVWest" ValidationGroup="UpdateBBG" runat="server"
                           ValidationExpression="^[0-9]{1,9}((\,)[0-9]{1,2})?$" ControlToValidate="tbKVWest" SetFocusOnError="true">*</asp:RegularExpressionValidator>
              </EditItemTemplate>
              <ItemTemplate>
                  <%# Eval("KVWestFormatted")%>
              </ItemTemplate>
        </asp:TemplateField>
....
      </Columns>
          <EmptyDataTemplate>Keine Daten vorhanden</EmptyDataTemplate>
  </asp:GridView>
      <p>
            <asp:ValidationSummary ID="vsUpdate3" runat="server" ShowMessageBox="true" ShowSummary="true" ValidationGroup="UpdateBBG" Font-Bold="true" ForeColor="Red" 
                 EnableClientScript="true" Enabled="true" HeaderText="Validierung..." />
      </p>

Would be nice if you guys could help me out here. Im not quite sure what the problem is .. maybe it's the UpdatePanel? Maybe I made some dumb mistake ..? I'm rather clueless.


回答1:


You button validation group is update but all other have validation group updatebbg so change validation group of ur button to updatebbg




回答2:


Found The problem .. I have to set the errormessage for both RequiredFieldValidator and RegularExpressionValidator. ;) You don't need the validationgroup inside of the textbox btw.



来源:https://stackoverflow.com/questions/15518798/validationsummary-doesnt-show-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!