Question

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.

Was it helpful?

Solution 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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top