DataGrid - Edit Command

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I can not seem to get my "EditCommand" event to fire. My code for the
datagrid looks like the following:

<asp:datagrid id="dgTask" runat="server" PagerStyle-Mode="NextPrev"
ShowFooter="True" PageSize="25"
OnPageIndexChanged="dgTask_PageChangeRequested"
PagerStyle-HorizontalAlign="Right" PagerStyle-CssClass="text12Bold"
PagerStyle-NextPageText="Next" PagerStyle-PrevPageText="Previous"
CellSpacing="2" BorderWidth="1px"
CellPadding="3" BackColor="#DEBA84" BorderStyle="None"
BorderColor="#DEBA84" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
OnSortCommand="dgTask_SortCommand" OnEditCommand="dgTask_EditCommand">
<FooterStyle Font-Size="10px" ForeColor="#8C4510"
BackColor="#F7DFB5"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#738A9C"></SelectedItemStyle>
<ItemStyle Font-Size="10px" ForeColor="#8C4510"
BackColor="#FFF7E7"></ItemStyle>
<HeaderStyle Font-Size="10px" Font-Bold="True" ForeColor="White"
BackColor="#A55129"></HeaderStyle>
......
</asp:datagrid>

My method looks like the following...

public void dgTask_EditCommand(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);
}
}

If I code the On_ItemCommand Event - that event fires and I can direct it to
the method identified above. Shoule it not just go directly to the method
above?

Thanks in advance for your assistance!!!
 
I think it would help if you boiled the sample code down to the bare basics,
and then included the complete sample code. So remove all formatting,
sorting etc, and try to post a real simple sample that - of course - doesn't
work when you click the edit column.

Jeppe Jespersen
 
Back
Top