Hi
You need to dynamically attach Image Click Event to the
Image buttons which are there in DataList.
Ravikanth
[quoted text, click to view] >-----Original Message-----
>I have two imagebuttons (A & B) on my page, and I am
trying to create
>events that when I click on image A, it becomes
invisible, and Image B
>becomes visible.
>
>I can get it all to work fine when I'm not using it
inside a DataList,
>but once I wrap a DataList around the table, I get
errors like: "Name
>'Button1' is not declared.
>
>Here is my html code that shows the Datalist, table, and
imagebutton
>info:
><code>
><table width="550" border="0">
><!-- BEGIN DataList dlCommEstate0 --
>
><asp:DataList ID="dlCommEstate0" runat="server"
gridlines="both">
><itemtemplate>
> <tr>
> <td colspan="5" nowrap> <p
align="center"><strong>Budget
>Report</strong></p></td>
> </tr>
> <tr>
> <td colspan="2" rowspan="3" nowrap> </td>
> <td colspan="3" class="Text"> </td>
> </tr>
> <tr>
> <td width="100" class="Text"><div
>align="center"><strong>Budget</strong></div></td>
> <td width="100" class="Text"><div
>align="center"><strong>Actuals</strong></div></td>
> <td width="100" class="Text"><div
>align="center"><strong>Variance</strong></div></td>
> </tr>
> <tr>
> <td width="100" class="Text"><div
>align="center"><strong>Period</strong></div></td>
> <td width="100" class="Text"><div
>align="center"><strong>Period</strong></div></td>
> <td width="100" class="Text"><div
>align="center"><strong>Period</strong></div></td>
> </tr>
> <tr>
> <td width="20" nowrap><div align="center">
><asp:ImageButton id=Button1
ImageUrl="/vista/images/expand.gif"
>width="15" height="15" BorderWidth="2px"
>onclick="ImageButton1_OnClick" runat="server"
visible="true" />
><asp:ImageButton id=Button2
ImageUrl="/vista/images/collapse.gif"
>width="15" height="15" BorderWidth="2px"
>onclick="ImageButton2_OnClick" runat="server"
visible="false" />
> </td>
> <td width="200" nowrap class="update-fields"><div
>align="right"><strong>Rental Revenues</strong></div></td>
> <td width="100" class="Text"></td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> </tr>
> <tr>
> <td width="20" nowrap><div
align="center"> </div></td>
> <td width="200" nowrap class="Text"><div
align="right">Third Party
>Rent</div></td>
> <td width="100" class="Text"><asp:Label id=Label1
runat=server
>/></td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> </tr>
><asp:Panel id="pnlRevenue" visible="true">
> <tr>
> <td width="20" nowrap><div
align="center"></div></td>
> <td nowrap class="Text"><div align="right">Ad
Hording</div></td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> </tr>
> <tr>
> <td width="20" nowrap><div align="center"></div></td>
> <td width="200" nowrap class="Text"><div
>align="right">Aerials</div></td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> </tr>
> <tr>
> <td width="20" nowrap><div align="center"></div></td>
> <td width="200" nowrap class="Text"><div
>align="right">Parking</div></td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> </tr>
> <tr>
> <td width="20" nowrap><div align="center"></div></td>
> <td width="200" nowrap class="Text"><div
>align="right">SubStations</div></td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> </tr>
></asp:Panel>
> <tr>
> <td width="20" nowrap><div align="center"></div></td>
> <td width="200" nowrap class="Text"><div
align="right"><strong>Sub
>Totals</strong></div></td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> <td width="100" class="Text"> </td>
> </tr>
></itemtemplate>
></asp:DataList>
> </table>
><!-- END DataList dlCommEstate0 -->
></code>
>
>And here is the onClick code foreach of the imagebuttons:
><code>
>'Event for Expand button click. Show Collapse button,
hide Expand
>button
>Sub ImageButton1_OnClick(sender As Object, e As
ImageClickEventArgs)
> Button1.Visible = "False"
> Button2.Visible="True"
>End Sub
>
>'Event for Collapse button click. Show Expand button,
hide Collapse
>button
>Sub ImageButton2_OnClick(sender As Object, e As
ImageClickEventArgs)
> Button2.Visible = "False"
> Button1.Visible="True"
>End Sub
></code>
>
>The error I get is: "Name 'Button1' is not declared" in
the
>ImageButton1_OnClick event. So I guess my question is,
how do I
>declare those imagebuttons in order to use them in the
datalist??
>
>TIA.
>.