Solved

Hiding a control in a TemplateField in a GridView

Posted on 2011-09-29
3
281 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

806 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