Link to home
Start Free TrialLog in
Avatar of TrialUser
TrialUserFlag for Afghanistan

asked on

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")%>' />                                                        
ASKER CERTIFIED SOLUTION
Avatar of iHadi
iHadi
Flag of Syrian Arab Republic image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nasir Razzaq
> I want to trigger the button click and do some server side code.
Programmatically? From client side or server side?