Question : GridView Update is triggering validation

On the same ASP.NET page, I have a form for users to enter job info.  Below the form, I have a datagrid that displays the users jobs.  So when then click 'Add Job', the page refreshed and the grid relects the new entry.

The problem is that when I click Edit in the grid, then Update - the forms required field validators kick in and prevent the grid from making the update.  

Should I use update panels for this?  I tried and could quite get it working.  Or is there some code I can put in the edit event to ignore the validators?

Thanks,

Justin

Answer : GridView Update is triggering validation

Hi

Use the validationGroup property for the controls and the validators that needs to be triggered...

an samll eg for understanding

<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" Runat="server" ValidationGroup="First"></asp:TextBox>

<asp:TextBox ID="TextBox2" Runat="server" ValidationGroup="First"></asp:TextBox><br />

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server" ValidationGroup="First"
ErrorMessage="TextBox1 should not be blank" ControlToValidate="TextBox1">

</asp:RequiredFieldValidator>
<asp:Button ID="Submit1" Runat="server" ValidationGroup="First" Text="Submit 1" />

<br />
<br />

<asp:TextBox ID="TextBox3" Runat="server" ValidationGroup="Second"></asp:TextBox>

<asp:TextBox ID="TextBox4" Runat="server" ValidationGroup="Second"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" Runat="server" ErrorMessage=" TextBox3 should not be blank"
ControlToValidate="TextBox3" ValidationGroup="Second">
</asp:RequiredFieldValidator>

<asp:Button ID="Submit2" Runat="server" ValidationGroup="Second" Text="Submit 2" />

</div>
</form>
</body>
Random Solutions  
 
programming4us programming4us