ASP.Net Update Panel GridView does not fire Child Trigger events due to Validator in Template Column
Found this issue while working on a GridView page, when we have a RequiredFieldValidator which should work in a FooterTemplate
for new records, this prevents Child control events to fire such as Button, the safe bet is to avoid Asp.Net Validators and use
JS client side to validate when dealing with Update Panels with GridViews.
This Doesnt Work:
<asp:TemplateField HeaderText="Resource Last Name" ItemStyle-Width = "100px" SortExpression="Resource_Last_Name">
<ItemTemplate>
<asp:Label ID="lblResource_Last_Name" runat="server" Text='<%# Eval("Resource_Last_Name") %>'></asp:Label>
<asp:TextBox ID="txtResource_Last_Name" runat="server" Text='<%# Eval("Resource_Last_Name") %>' Visible="false"></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtResource_Last_Name" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtResource_Last_Name"
Display="Dynamic" ErrorMessage="You must enter a last name." ForeColor="">*</asp:RequiredFieldValidator>
</FooterTemplate>
<FooterStyle Wrap="False" />
</asp:TemplateField>
This is OK:
<asp:TemplateField HeaderText="Resource Last Name" ItemStyle-Width = "100px" SortExpression="Resource_Last_Name">
<ItemTemplate>
<asp:Label ID="lblResource_Last_Name" runat="server" Text='<%# Eval("Resource_Last_Name") %>'></asp:Label>
<asp:TextBox ID="txtResource_Last_Name" runat="server" Text='<%# Eval("Resource_Last_Name") %>' Visible="false"></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtResource_Last_Name" runat="server"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False" />
</asp:TemplateField>
No comments:
Post a Comment