A little confused by the example:
1) Is the example missing the following, or are the doEdit, doCancel method
just for the record creation?
OnUpdateCommand="doEdit" OnCancelCommand="doCancel"
2) I have
<asp:datagrid id="UsersDataGrid" runat="server" DataKeyField="objId"
OnSortCommand="SortUser_OnClick"
AllowSorting="true" AutoGenerateColumns="False" ShowHeader="true"
OnItemCommand="doInsert" ShowFooter="True"
OnUpdateCommand="UsersDataGrid_Update"
OnCancelCommand="UsersDataGrid_Cancel" OnEditCommand="UsersDataGrid_Edit">
<asp:TemplateColumn SortExpression="ExampleCol" HeaderText="example">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "ExampleCol") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="ExampleCol" Columns="5" Text='<%#
DataBinder.Eval(Container.DataItem, "ExampleCol") %>' Runat="server" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="addExampleCol" Columns="5" Runat="Server" />
</FooterTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn EditText="Edit" CancelText="Cancel"
UpdateText="Update" />
<asp:TemplateColumn>
<FooterTemplate>
<asp:Button CommandName="doInsert" Text="Add" ID="btnAdd"
Runat="server" />
</FooterTemplate>
</asp:TemplateColumn>
protected void doInsert(Object sender, DataGridCommandEventArgs e)
{
((TextBox) e.Item.FindControl("addExampleCol")).Text= "Hello!";
}
I have put a breakpoint within doInsert, but the code does not reach the
breakpoint!!
3) Also, is it possible to have Edit link on each row, but the Add
link/button at footer? If so, how? I try moving EditCommandColumn into the
ItemTemplate of the add record column, but it doesn't work.