Click here to Skip to main content
15,890,370 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi, i have a datalist as follow
XML
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" style="z-index: 108; left: 733px; position: absolute; top: 72px" >
          <ItemTemplate><asp:Image ID="uximage" runat="server" /></ItemTemplate>
        </asp:DataList>


i want to find id of the image control in that datalist.
for that i have written code as (in button click event)

as
C#
protected void Button4_Click(object sender, EventArgs e)
   {


C#
foreach(DataListItem item in DataList1.Items)
{
Image im = (Image)item.FindControl("uximage");
im.ImageUrl = "Handler.ashx";
}

}

When i execute the application and when i click on button view all image
.it is not going through the body of foreach .
also when i put a break point and checked the DataList1.Items it is showing the count as 0.
what is wrong in this code ,please help
Posted

1 solution

Did you try executing your code from within the Datalist's ItemCommand event.
 
Share this answer
 
Comments
software_Engi08 11-Nov-10 12:35pm    
no,but why i should need a itemcommand ,i want to view all image in a button click event.i have a datalist as <asp:DataList ID="DataList1" runat="server" RepeatColumns="3" style="z-index: 108; left: 733px; position: absolute; top: 72px" >
<itemtemplate><asp:Image ID="uximage" runat="server" />
</asp:DataList>
please this time send me some correct code(the exact code) and also i want to bind the image control as 3 pic in one row and 2 in other row from the database having 5 pic.how could i do this ,send me some exact code.please

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