Data Grid Event Fires Twice..

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);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top