FindControl with GridView

  • Thread starter Thread starter sck10
  • Start date Start date
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>
 
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
 
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>
 
Back
Top