troubleshooting Question

Linking ItemCommand in Datagrid embedded in DataList

Avatar of rogerfg7
rogerfg7 asked on
.NET ProgrammingASP.NET
3 Comments1 Solution579 ViewsLast Modified:
We have a DataGrid embedded in a DataList.  The DataList can display mulitple records (if present) and the DataGrid displays children records of the parent.  We want to be able to provide  delete function for the child records and have added the following column to the <Columns>

<asp:TemplateColumn HeaderText="Delete" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40px">
  <ItemTemplate>
    <asp:ImageButton ID="btnDelete" ImageUrl="~/images/delete.gif" Runat="server" AlternateText="Delete" CommandName="Delete" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"UserID")+","+DataBinder.Eval(Container.DataItem,"CustomerID")+","+DataBinder.Eval(Container.DataItem,"SubscriptionID")%>'>
    </asp:ImageButton>
  </ItemTemplate>
</asp:TemplateColumn>

The DataGrid does not display in the designer, so we are attempting to bind the ItemCommand event handler in the DataList ItemDataBound event

BulkSubscriptionController bc = new BulkSubscriptionController ();

DataGrid grd = (DataGrid)e.Item .FindControl ("grdSubscribedUsers");
grd.DataSource = bc.GetBulkSubscriptionUsers (bsi.CustomerID,bsi.SubscriptionID);
grd.DataBind ();
grd.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdSubscribedUsers_ItemCommand);

However, the grdSubscribedUsers_ItemCommand does not fire on clicking the btnDelete image, although the form does PostBack.

Any assistance would be gratefully appreciated

Many thanks

Roger Graham
ASKER CERTIFIED SOLUTION
tovvenki

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros