Gridview and EmptyDataTemplate in Edit mode

  • Thread starter Thread starter j-in-uk
  • Start date Start date
J

j-in-uk

Hi,

I am using the gridView control at first the EmptyInsert command is
executed from the EmptyDataTemplate but when a user clicks Edit after
the 1st insert, for some reason it detects the rowtype as empty datarow
and does not go to Edit mode but displays all the controls from
EmptyDataTemplate instead.

what am i missing?


protected void gvProducts_RowEditing(object sender,
GridViewEditEventArgs e)
{
gvProducts.EditIndex = e.NewEditIndex;
gvProducts.ShowFooter = false; // We also turn off the add
screen while updating data
BindgvProducts();
}

<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:Label ID="lblQty" runat="server" Text='<%# Eval("Quantity")
%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtQty" runat="server" Text='<%# Bind("Quantity")
%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtQty" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<EditItemTemplate>
<asp:LinkButton ID="LinkButtonUpdate" runat="server"
CausesValidation="true" CommandName="Update" Text="Update" />
<asp:LinkButton ID="LinkButtonCancel" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button Text="Insert" CommandName="Insert" CausesValidation="true"
runat="server" ID="btInsert" UseSubmitBehavior="false" />
</FooterTemplate></asp:TemplateField>
<EmptyDataTemplate>
<table>
<tr><td>Select Product</td><td>Quantity</td></tr>
<tr>
<td><asp:DropDownList ID="ddEmptyProductList"
runat="server"></asp:DropDownList></td>
<td><asp:TextBox ID="txtEmptyQty"
runat="server"></asp:TextBox></td></tr></table>
<asp:Button ID="btSend" Text="Insert" class="inputBtns" runat="server"
CausesValidation="false" CommandName="EmptyInsert"
UseSubmitBehavior="false" />
</EmptyDataTemplate>
 
Back
Top