Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i retrieve from data base id of JOKE and if it like or not

all what i want to find the control inside my data list with the commandargument= id that i retrieve
Posted
Comments
DamithSL 31-May-14 1:12am    
update the question with related code

Give command name field for Control like this:

XML
<ItemTemplate>
<asp:ImageButton ID="Image1" runat="server" CommandArgument='<%# Eval("product_id") %>' CommandName="click" Height="200px" ImageUrl='<%# Eval("url")%>' Width="200px" />
        </ItemTemplate>



and then in code behind:

C#
protected void Datalist1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "click")
        {
            // your logic
        }
     }
 
Share this answer
 
inside item command event you can find controls as below
e.g if you have TextBox with id Txt1

C#
TextBox txt1 = e.Item.FindControl("Txt1") as TextBox; 
 
Share this answer
 
Comments
asmaaelshabaka 31-May-14 2:39am    
i need it in the page load

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900