I'm developing a web page in Asp.Net 1.1 and have a DataGrid which allows users to add, edit, and delete database records. The footer row contains textboxes to allow the adding of new records.
For each column I've defined <ItemTemplate>, <EditItemTemplate> and <FooterItemTemplate> elements. The FooterItemTemplate and EditItemTemplate elements in my aspx markup both contain RequiredFieldValidator controls as well as text boxes. (see below)
<asp:TemplateColumn HeaderText="Offer Code">
<ItemTemplate>
<%# DataBinder.Eval(Container, "DataItem.OfferCode") %>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewOfferCode" Runat="server" />
<asp:RequiredFieldValidator ID="reqNewOfferCode" ControlToValidate="txtNewOfferCode" Display="None" ErrorMessage="Please specify 'Offer Code'" Runat="server" />
</FooterTemplate>
<EditItemTemplate>
<asp:TextBox id=txtOfferCode Runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.OfferCode") %>' />
<asp:RequiredFieldValidator ID="reqOfferCode" ControlToValidate="txtOfferCode" Display="None" ErrorMessage="Please specify 'Offer Code'" Runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
The problem I have is that when you try to edit an existing record, the blank fields in the footer row prevent validation and hence postback and updating of the selected row.