I'm at my wits end. I've googled, scoured more than my share of
articles, and I'm still stumped as to why my datagrid is not firing
the CancelItem or UpdateItem events.

I'm using a datagrid with one boundcolumn, a few templatecolumns, and
an editcommandcolumn. I'm using the footertemplate to have a 'new
item' row. I have the datagrid's ItemCommand and CancelCommand wired
up to my functions in the code behind (instead of specifying the
method names in the <asp:datagrid> tag).

When run, the Edit link works fine, it does its job and renders the
edittemplated portion of the datagrid. But when I click the "cancel"
linkbutton, the page is posted back, but no ItemCommand or
CancelCommand events are fired. I've pasted the code below. What am I
missing?

The datagrid tag:

<asp:datagrid 
                id="dgRightNavLinks"
                runat="server" 
                autogeneratecolumns="False"
                showheader="True"
                showfooter="True"
                edititemstyle-backcolor="#CCCCCC"
                >
<columns>
<asp:boundcolumn visible="False"
datafield="PageLinkID"></asp:boundcolumn>
<asp:templatecolumn headertext="Link URL">
<itemtemplate>
                <%# DataBinder.Eval(Container.DataItem,"LinkTarget") %>
</ItemTemplate>
<footertemplate>
                <asp:textbox id="addLinkTarget" runat="server" columns="20"
maxlength="250" />
</FooterTemplate>
<edititemtemplate>
                <asp:textbox id="txtLinkTarget" runat="server" columns="20"
maxlength="100" text='<%#
DataBinder.Eval(Container.DataItem,"LinkTarget") %>'></asp:textbox>
</EditItemTemplate>

</asp:templatecolumn>

<asp:templatecolumn headertext="Link Description">
<itemtemplate>
                <%# DataBinder.Eval(Container.DataItem,"LinkDescription")%>
</ItemTemplate>
<footertemplate>
                <asp:textbox id="addLinkDescription" runat="server" columns="20"
maxlength="100"></asp:textbox>
</FooterTemplate>
<edititemtemplate>
                <asp:textbox id="txtLinkDescription" runat="server" columns="20"
maxlength="100" text='<%#
DataBinder.Eval(Container.DataItem,"LinkDescription")%>'></asp:textbox>
</EditItemTemplate>
</asp:templatecolumn>

<asp:editcommandcolumn buttontype="LinkButton" updatetext="Update"
canceltext="Cancel" edittext="Edit"></asp:editcommandcolumn>

<asp:templatecolumn>
<itemtemplate>
                <asp:linkbutton commandname="Delete" text="X" id="btnDel"
runat="server" cssclass="errorMessage" />
</ItemTemplate>
<footertemplate>
                <asp:linkbutton commandname="Insert" text="Add" id="btnAdd"
runat="server" />
</FooterTemplate>
</asp:templatecolumn>
</Columns>
</asp:datagrid>

And as for the wiring of delegates, I have:

private void InitializeComponent()
{
this.dgRightNavLinks.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgRightNavLinks_ItemCommand);
this.dgRightNavLinks.CancelCommand+=new
DataGridCommandEventHandler(dgRightNavLinks_CancelCommand);

...
}

Note I do have the event handlers written out; they're not included
here for brevity.

(Thanks for any insight)
Scott




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to