Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TemplateField in Child Gridview

Status
Not open for further replies.

rsshetty

Programmer
Dec 16, 2003
236
US
I have a gridview inside a datalist. In this gridview I have a templatefield.

Code:
<asp:DataList ID="dlParent" runat="server" OnItemDataBound="dlParent_ItemDataBound">
                    <ItemTemplate>
                    <asp:GridView ID="gvStudentList" runat="server" AutoGenerateColumns="false"  
                        OnRowDataBound="gvStudentList_RowDataBound" OnRowCreated="gvStudentList_RowCreated"
                        BorderStyle="solid" BorderWidth="1" Font-Names="Verdana" Font-Size="smaller">
                        <HeaderStyle Font-Bold="True" Font-Size="X-Small" ForeColor="Black" Height="20px" HorizontalAlign="Center"/>
                        <RowStyle BackColor="#ffffff" HorizontalAlign="Center" BorderStyle="outset" BorderWidth="2"/>
                        <FooterStyle BackColor="#ffffff" />
                        <Columns> 
                        
                        
                        
                        
                        <asp:TemplateField HeaderText="LNF" visible="false" ItemStyle-Width="15%">
                            <ItemTemplate>
                                <asp:Label ID="lblLNF" runat="server" visible="false"></asp:Label>

....


In the RowDataBound event of the child gridview, I am unable to set the templatefield visibility to true.

Does anyone know how to do this?


rsshetty.
It's always in the details.
 
How are you trying to do it now? I suggest using FindControl to get the object then set the visible property.
 
When I try e.Row.FinControl("gvStudentList"), I get a message saying that gvStudentList is not available int he current context. The error message is valid as I am looking for a GridViw in the row of the GridView. What I actually need is the ability to access the templatefield itself.

Ideas?

rsshetty.
It's always in the details.
 
Actually, never mind. I got it to work.

((GridView)sender).Columns[0].Visible = true;


That did the trick.

rsshetty.
It's always in the details.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top