[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 937
  • Last Modified:

Triggerring ItemCommand to trigger a button click inside a Datalist

I have a datalist contorl inside which I have a button. I want to trigger the button click and do some server side code. I have the following code in the seerver side and client side. But I am not able to trigger this event at all. Please help. Am I using the right event to trigger the button click or should I use a diff. one. Please help thanks

Private Sub dlProduct_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlProduct.ItemCommand
If e.CommandName = "AddCart" Then
'some code
End Sub

<asp:DataList ID="dlProduct" runat="server" OnItemCommand ="dlProduct_ItemCommand">
                                    <ItemStyle Font-Bold="True" />
                                    <ItemTemplate>
<asp:ImageButton  ID="imgTopAddtoCart" runat="server" ImageAlign="Right" ImageUrl="/Assets/Images/Products/AddtoCart.jpg"  CommandName="AddCart" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ItemID")%>' />                                                        
0
TrialUser
Asked:
TrialUser
1 Solution
 
iHadiCommented:
Hi,

Make sure that the following line exists in the IntializeComponent() of your page and if not, add it.

this.dlProduct.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlProduct_ItemCommand);
0
 
CodeCruiserCommented:
> I want to trigger the button click and do some server side code.
Programmatically? From client side or server side?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now