Control panel visibility inside datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
i have a template column in datagrid. Inside template column i have panel. I
want to control the visibility of the panel with checkbox. can this be done?

<asp:TemplateColumn>
<ItemTemplate>
<asp:Panel id="pnlDocumentDetailsGrid" runat="server"
Visible="False">
<TABLE id="Table112" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR bgColor="#1d4076">
<TD width="1%"> </TD>
<TD align="left">
<FONT style="FONT-WEIGHT: bold; FONT-SIZE: 12pt;
FONT-FAMILY: Arial" color="#c3daff">
<%# Container.DataItem("description")%>
</FONT>
</TD>
<TD align="right">
<FONT style="FONT-WEIGHT: bold; FONT-SIZE: 12pt;
FONT-FAMILY: Arial" color="#c3daff">
Bulletin: <%# Container.DataItem("uploaddate")%>
</FONT>
</TD>
<TD>
<IMG src="../images/Curly.jpg"></TD>
</TR>
</TABLE>
</asp:Panel>
</ItemTemplate>
</asp:TemplateColumn>

Here is my codebehind itemdatabound event:


Sub dGridAvailableDocuments_Bound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs)
If cBoxDocDetails.Checked Then
e.Item.FindControl("pnlDocumentDetailsGrid").Visible = True
End If

End Sub

Thanks

Manny
 
Manny,

It's a client-side task. In ItemDataBound event add "onclick" attribute to
the checkbox. It will be your client-side onclick event handler. In the
handler you will need to find the panel by it's id and control it's
visibility via style.display or style.visibility properties. You will want
to pass the panel ClientId from the server to the checkbox's onclick event
handler.

Eliyahu
 
Back
Top