Click here to Skip to main content
15,885,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Datalist have image control and checkbox.where image are retriving from databse. when i click one of row's checkbox then other row's image will change.How i solve it by asp.net using csharp?

Here is my datalist:

XML
<asp:DataList ID="DataList" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
   Width="50%" BorderColor="#336699" BorderStyle="Solid" BorderWidth="2px"   >

   <ItemTemplate>
      <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductName") %>' Font-Bold="True"
         Font-Size="10pt" ForeColor="#336699" Width="100%" />
      <br />
      <asp:Image ID="Image1" runat="server" Width="100px" Height="120px"
         ImageUrl='<%# "GetImage.aspx?id=" + Eval("ProductID") %>' />
         <asp:CheckBox ID="CheckBox1" runat="server" onclick = "CheckBox_Clicked(this)" />
          <asp:HiddenField ID="HiddenCatID" runat="server" Value='<%# Eval("ProductID") %>' />
   </ItemTemplate>
   <ItemStyle HorizontalAlign="Center" VerticalAlign="Top"  />
</asp:DataList

>
Posted
Comments
/\jmot 27-Feb-15 16:59pm    
debug and find the problem, be clear.

1 solution

Inside the CheckBox Click Event, you can get the Current GridViewRow. Then find the next Row's Index and retrieve that Row. Now, find the Image Control of this Row and do whatever you want to do.

Refer - CASCADING DROPDOWNLIST ON GRIDVIEW[^].

See the DropDownList SelectedIndexChanged Event explained in the Blog and how to get the Row inside that Event. You just need to use use CheckBox Click Event and follow the same procedure to get the Current Row. Then get the next Row Index and next Row and do as I said.
 
Share this answer
 
Comments
Member 11072671 3-Mar-15 23:23pm    
Please give me example. I have tried to follow above example. But i failed.
DropDownList ddlCity = (DropDownList)currentRow.FindControl("ddlCity");Exachange of above line , when i write Image image = (Image)currentitem.FindControl(Image1); this statement i get error.
What will i write to exachange of this line?
Tell me how you found the currentRow inside the Event?
Member 11072671 5-Mar-15 13:01pm    
i don't know.
If you can't tell me what you tried, then how can I help you?

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