I've tried it but it still wont fire the event.
Here is the code:
protected void Page_Load(object sender, EventArgs e)
{
SetLinkedTable(GetSource())
}
private void SetLinkedTable(DataTable source)
{
gvLinkedTable = (GridView)skin.FindControl("gvLinkedTable");
AttachEvents();
gvLinkedTable.DataSource = source;
gvLinkedTable.DataBind();
this.Controls.Add(skin);
}
private void AttachEvents()
{
gvLinkedTable.RowCommand +=new
GridViewCommandEventHandler(gvLinkedTable_RowComma nd);
gvLinkedTable.RowDataBound += new
GridViewRowEventHandler(gvLinkedTable_RowDataBound );
}
private void gvLinkedTable_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
int pk = Convert.ToInt32(e.CommandArgument);
DeleteItem(pk);
SetLinkedTable(dt);
}
}
"clickon" <cl*****@discussions.microsoft.comwrote in message
news:D8**********************************@microsof t.com...
The order that event handlers execute can cause this kind of problem. Why
are
you setting the command argument of the delete button in the RowDataBound
event, why not just declare it in the markup? Try that and see if the
RowCommand event fires.
"Kevin Attard" wrote:
>I am using a GridView inside a UserControl which has a template column
for
deleting the rows. Before databinding the gridview i am attaching the
RowCommand and RowDataBound event.
I am using the RowDataBound event to set the commandargument of the
delete
button. The event is being fired and works fine.
When I press the delete button, the RowCommand event is not firing! and
neither is the RowDeleting (the button's commandName is "Delete")
Any idea why?