Click here to Skip to main content
16,020,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My source page code as follows

XML
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
        <ajaxToolkit:TabPanel ID ="tbfaculty" runat ="server">

        <HeaderTemplate>
          Faculty
        </HeaderTemplate>


            <ContentTemplate>
           <asp:Panel id="pnlfac" runat="server" backcolor="White" bordercolor ="Black" borderstyle="Solid" borderwidth="1px" height="144px">
           <asp:GridView id="gvfaculty" runat="server" backcolor="LightGoldenrodYellow" BorderColor="Tan" width="91px" autogeneratecolumns = "False" ForeColor="Black">
           <FooterStyle BackColor="Tan" />
                    <HeaderStyle BackColor="Tan" Font-Bold="True" />
                    <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                    <Columns>
                     <asp:BoundField DataField="Faculty Name" HeaderText="Faculty Name" />


              <asp:TemplateField HeaderText="Does the Faculty come well prepared for his subject">
                 <ItemTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true">
                <asp:ListItem Value="-1">--Select Rating --</asp:ListItem>
                </asp:DropDownList>
               </ItemTemplate>
        </asp:TemplateField>


         <asp:TemplateField HeaderText="Is he loud and clear in his speech">
                 <ItemTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true">
                <asp:ListItem Value="-1">--Select Rating --</asp:ListItem>
                </asp:DropDownList>
               </ItemTemplate>
        </asp:TemplateField>









in run mode in tab container as follows

Faculty
When i click the faculty in tab container i want to show the gridview.


for display the gridview content in tab container i written a code as follows

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
Facultybindgrid();
}
catch
{

}
}
}

private void Facultybindgrid()
{
DataTable dt = new DataTable();
dt.Rows.Add(&quot;CPG&quot;);
dt.Rows.Add(&quot;BSR&quot;);
gvfaculty.DataSource = dt;
gvfaculty.DataBind();
gvfaculty.Visible = true;
}

but when i run and click the faculty in tab container the gridview is not displaying.

please help me.from my above code what is the mistake i made.

regards
Jegan B
Posted
Comments
My guess is when you click the Tab Container, it posts back, so the Faculty Bind method is not called as it is inside the IsPostBack.

1 solution

you haven't define columns in your GridView, by setting AutoGenerateColumns as false will prevent generating columns automatically. at the end you will not see any record.
set AutoGenerateColumns= "true"
<asp:GridView id="gvfaculty" runat="server" backcolor="LightGoldenrodYellow" BorderColor="Tan" width="91px" autogeneratecolumns = "true" ForeColor="Black">
 
Share this answer
 
v3
Comments
[no name] 5-Jun-14 2:17am    
thanks it is working fine here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900