Solved

Hiding a control in a TemplateField in a GridView

Posted on 2011-09-29
3
288 Views
Last Modified: 2012-08-14
I have the following Template field in a GridView:

               <asp:TemplateField HeaderText="PIP">
                <ItemTemplate>
                <asp:Label runat="server" Text='<%#Eval("PIP") %>'></asp:Label>
                <asp:CheckBox ID="chkPIP" runat="server" />
                </ItemTemplate>
                </asp:TemplateField>

On some rows, I do not want the CheckBox to be visible or at least not checkable.

I am trying to use the RowDataBound event, but I can't figure out how to reference my checkbox control.

Can anyone show me how?
0
Comment
Question by:AIBMass
3 Comments
 
LVL 4

Expert Comment

by:rar3z
ID: 36818810
I needed to some something similar to that, I remember I had to build the GridView using code behind only then you would be able to reference it and it would be dynamic.

I think the link I followed was this.

Building a referencable dynamic gridview
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
ID: 36819003
onrowdatabound event write code as below.
CheckBox chk=(CheckBox)e.Row.Findcontrol("chkPIP");
chk.Visible=False;
Or
chk.Enabled=false;
0
 

Author Closing Comment

by:AIBMass
ID: 36891282
Completely perfect. Thanks.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question