DataGrid - Edit Command

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!!!
 
J

Jeppe Dige Jespersen

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
 

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,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top