G
Guest
Why does the method for on_ItemCommand fire twice when I press a button
contained within my grid?
My dgTask_ItemCommand which is the procedure name assigned to the
"on_ItemCommand" fires twice each and every time I press the button or link.
Why?
I have a datagrid in which I have and column defined as follows:
<asp:ButtonColumn Text="Edit" HeaderText="Edit"
CommandName="EditTask"></asp:ButtonColumn>
In the definition of the grid I have the following event defined...
OnItemCommand="dgTask_ItemCommand"
My method for dgTask_ItemCommand looks like the following:
public void dgTask_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "EditTask")
{
int itemOffSet = 0;
if (dgTask.CurrentPageIndex > 0)
{ itemOffSet = dgTask.CurrentPageIndex * dgTask.PageSize; }
_EditRowID = (e.Item.ItemIndex + itemOffSet);
if (ViewState["EditRowID"] == null)
{ ViewState.Add("EditRowID", _EditRowID); }
else
{ ViewState["EditRowID"] = _EditRowID; }
dgTask_Edit_Command(_DvTask[_EditRowID].Row);
}
}
contained within my grid?
My dgTask_ItemCommand which is the procedure name assigned to the
"on_ItemCommand" fires twice each and every time I press the button or link.
Why?
I have a datagrid in which I have and column defined as follows:
<asp:ButtonColumn Text="Edit" HeaderText="Edit"
CommandName="EditTask"></asp:ButtonColumn>
In the definition of the grid I have the following event defined...
OnItemCommand="dgTask_ItemCommand"
My method for dgTask_ItemCommand looks like the following:
public void dgTask_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "EditTask")
{
int itemOffSet = 0;
if (dgTask.CurrentPageIndex > 0)
{ itemOffSet = dgTask.CurrentPageIndex * dgTask.PageSize; }
_EditRowID = (e.Item.ItemIndex + itemOffSet);
if (ViewState["EditRowID"] == null)
{ ViewState.Add("EditRowID", _EditRowID); }
else
{ ViewState["EditRowID"] = _EditRowID; }
dgTask_Edit_Command(_DvTask[_EditRowID].Row);
}
}