Vote count:
0
I have textboxes and a grid view. Inside grid view there are text boxes which are also validating. And in the footer there is a button which create new row if grid view current row pass the validation.
The problem is that when buton inside grid view is pressed it also validates the contents outside the grid. How to control this?
My aspx code is as:
<h4>Worked Date</h4>
<asp:TextBox runat="server" ID="txtDateOfWorkForInserting" CssClass="form-control" EnableViewState="false" ClientIDMode="Static" ValidateEmptyText="true"/>
<asp:RequiredFieldValidator ID="rfvDateOgWork"
CssClass="text-danger" ControlToValidate="txtDateOfWorkForInserting"
runat="server" EnableViewState="true" ErrorMessage="*" ToolTip="Select Date" Display="Dynamic" ></asp:RequiredFieldValidator>
<asp:GridView ID="gvWorkDone" runat="server" ShowFooter="True" AutoGenerateColumns="False"
CellPadding="4" GridLines="None" OnRowDeleting="gvWorkDone_RowDeleting" CssClass="table-responsive table table-striped"
Style="text-align: left" >
<Columns>
<asp:BoundField DataField="RowNumber" HeaderText="SNo" />
<asp:TemplateField HeaderText="Work Description">
<ItemTemplate>
<asp:TextBox ID="txtWorkDone" runat="server" CssClass="form-control multilineTextbox" TextMode="MultiLine" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtWorkDone"
ErrorMessage="*" SetFocusOnError="True" InitialValue="<% %>"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Time To Complete">
<ItemTemplate>
<asp:DropDownList runat="server" ID="ddlTotalTime">
<asp:ListItem Selected="True">1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddlTotalTime"
ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
</ItemTemplate>
<FooterStyle HorizontalAlign="Right" />
<FooterTemplate>
<asp:Button ID="ButtonAdd" runat="server" Text="Add New Row" OnClick="ButtonAdd_Click" CausesValidation="false"/>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire