Hi
I tried to use TemplateField instead using CommandField then it removed the error because it avoid calling method from XMLDataSource.
This is my sample code. For CommandName attribute, do not use "Edit", "Update" or "Cancel" because it will try to call specified method from XMLDataSource and will give Error.
<asp:TemplateField HeaderText = "Options">
<ItemTemplate>
<asp:LinkButton ID="EditLinkButton" runat="server" Text="Edit" CommandName="EditCommand"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="UpdateLinkButton" runat="server" Text="Update" CommandName="UpdateCommand"></asp:LinkButton>
<asp:LinkButton ID="CancelLinkButton" runat="server" Text="Cancel" CommandName="CancelCommand"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
LinkButton sourceLinkButton = (LinkButton)e.CommandSource;
int rowIndex = ((GridViewRow)sourceLinkButton.Parent.Parent).RowIndex;
if (e.CommandName == "EditCommand")
{
GridView1.EditIndex = rowIndex;
}
else if (e.CommandName == "UpdateCommand")
{
/* Update method will be here */
GridView1.EditIndex = -1;
GridView1.DataBind();
}
else if (e.CommandName == "CancelCommand")
{
GridView1.EditIndex = -1;
}
}
Hope this help
Jeongwon