Solved

Hiding a control in a TemplateField in a GridView

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now