I have a gridview populated from a DataSet. I want to provide a row at the bottom of the gridview with text boxes in ready for a user to enter data, click an Add button so I can add a new record.
I have got the extra row in the GridView appearing by doing this:
The code for the GridView is this:Code:DataRow myRow = ds.Tables[1].NewRow(); ds.Tables[1].Rows.InsertAt(myRow, ds.Tables[1].Rows.Count); gvRecord.DataSource = ds.Tables[1]; gvRecord.DataKeyNames = new string[] { "RecordDetailID" }; gvRecord.DataBind();
So, all I have so far is an extra row appearing at the bottom of the GridView with the 'Edit' link button in it.Code:<asp:GridView ID="gvRecord" runat="server" AutoGenerateColumns="False" CssClass="Grid" Width="640"> <RowStyle CssClass="GridItem" /> <AlternatingRowStyle CssClass="GridAltItem" /> <EditRowStyle BackColor="White" /> <HeaderStyle CssClass="GridHeader" /> <EmptyDataTemplate><p class="instruct">This record does not have any details yet.</p></EmptyDataTemplate> <Columns> <asp:BoundField DataField="Description" HeaderText="Description" HeaderStyle-Wrap="false" HeaderStyle-Width="25%" /> <asp:BoundField DataField="Value" HeaderText="Value" HeaderStyle-Wrap="false" HeaderStyle-Width="25%" /> <asp:BoundField DataField="Price" HeaderText="Price" HeaderStyle-Wrap="false" HeaderStyle-Width="50%" /> <asp:TemplateField HeaderText="Edit" ItemStyle-Wrap="false"> <EditItemTemplate> <asp:LinkButton ID="lb1" runat="server" CommandName="Update" Text="Update"></asp:LinkButton> <asp:LinkButton ID="lb2" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton> </EditItemTemplate> <ItemTemplate> <asp:LinkButton ID="lb3" runat="server" CommandName="Edit" Text="Edit"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
My questions are:
How can I get text boxes into the last row?
How can I hide or remove the Edit LinkButton and, ideally, replace it with an Add button?
Thanks for any help.


Reply With Quote
