FindControl with GridView

S

sck10

Hello,

I have the following GridView. I need to be able to get to the DataFields
and set the Visible property. Any help with this would be appreciated.

Thanks, sck10


<!-- Grid: List of all the Services from the Textbox -->
<asp:GridView ID="gvSearchData" runat="server"
DataSourceID="dsSearchData"
DataKeyNames="Handle"
Width="100%">
<Columns>
<asp:BoundField DataField="strFullName"
Visible="true"
HeaderText="Name"
SortExpression=""
HeaderStyle-Cssclass="BlkB"
HeaderStyle-VerticalAlign="Bottom"
ItemStyle-HorizontalAlign="left"
ItemStyle-Width="15%" />

<asp:CheckBoxField DataField="IsActive"
Visible="true"
HeaderText="Active"
SortExpression=""
HeaderStyle-Cssclass="BlkB"
HeaderStyle-VerticalAlign="Bottom"
ItemStyle-HorizontalAlign="center"
ItemStyle-Width="7%" />
</Columns>
</asp:GridView>
 
B

Brandon Driesen

if it is the column that you wish to set globally, then
[C#]
gvSearchData.Columns[1].Visible = false;

[VB.NET]
gvSearchData.Columns(1).Visible = False
 
S

sck10

Thanks Brandon,

Just what I was looking for...

sck10


Brandon Driesen said:
if it is the column that you wish to set globally, then
[C#]
gvSearchData.Columns[1].Visible = false;

[VB.NET]
gvSearchData.Columns(1).Visible = False



sck10 said:
Hello,

I have the following GridView. I need to be able to get to the
DataFields and set the Visible property. Any help with this would be
appreciated.

Thanks, sck10


<!-- Grid: List of all the Services from the Textbox -->
<asp:GridView ID="gvSearchData" runat="server"
DataSourceID="dsSearchData"
DataKeyNames="Handle"
Width="100%">
<Columns>
<asp:BoundField DataField="strFullName"
Visible="true"
HeaderText="Name"
SortExpression=""
HeaderStyle-Cssclass="BlkB"
HeaderStyle-VerticalAlign="Bottom"
ItemStyle-HorizontalAlign="left"
ItemStyle-Width="15%" />

<asp:CheckBoxField DataField="IsActive"
Visible="true"
HeaderText="Active"
SortExpression=""
HeaderStyle-Cssclass="BlkB"
HeaderStyle-VerticalAlign="Bottom"
ItemStyle-HorizontalAlign="center"
ItemStyle-Width="7%" />
</Columns>
</asp:GridView>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top