Sunday, 15 September 2013

How to add footer to gridview

How to add footer to gridview

I have a grid with 3 columns - Edit, ID, Movie. I would like to add a
footer with an Insert link button, 2 textboxes respectively, but unable to
do so. Is it possible.
ASPX:
<asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="False"
OnRowEditing="gridview1_RowEditing"
OnRowCancelingEdit="gridview1_RowCancelingEdit"
ShowFooter="true" >
<Columns>
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true" />
<asp:BoundField DataField="id" HeaderText="ID" />
<asp:BoundField DataField="movie" HeaderText="MOVIE" />
</Columns>
</asp:GridView>
When I try the following, there is an error for commandfield which says,
this element is not supported.
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true" />
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="lnkInsert" runat="server"
Text="Insert"></asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</columns>
The other way would be to use itemTemplate & EditTemplate for each column
control. But I find this simple and would like to proceed this way. So Can
I add a footer to this structure.

No comments:

Post a Comment