在gridview中的ajax选项卡容器中显示asp.net中的记录 [英] in ajax tab container in gridview shows the record in asp.net

查看:75
本文介绍了在gridview中的ajax选项卡容器中显示asp.net中的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的源页面代码如下



 <  < span class =code-leadattribute> ajaxToolkit:TabContainer     ID   =  TabContainer1    runat   =  server    ActiveTabIndex   =  0 < span class =code-keyword>>  
< ajaxToolkit:TabPanel ID = tbfaculty runat = server >

< HeaderTemplate >
教师
< / HeaderTemplate >


< ContentTemplate >
< asp:Panel id = pnlfac runat = server backcolor = 白色 bordercolor = 黑色 borderstyle = Solid borderwidth = 1px height = < span class =code-keyword> 144px >
< asp:GridView id = gvfaculty runat = server backcolor = < span class =code-keyword> LightGoldenrodYellow BorderColor = Tan 宽度 = 91px autogeneratecolumns = False ForeColor = 黑色 < span class =code-keyword>>
< FooterStyle BackColor = Tan / >
< HeaderStyle BackColor = Tan Font-Bol d = True / >
< PagerStyle BackColor = PaleGoldenrod ForeColor = DarkSlateBlue Horizo​​ntalAlign = 中心 / >
< span class =code-keyword>< SelectedRowStyle BackColor = DarkSlateBlue ForeColor = GhostWhite / >
< >
< asp:BoundField DataField = 教师姓名 HeaderText = 教师姓名 / >


< asp:TemplateField HeaderText < span class =code-keyword> = 教师是否为他的主题做好了准备 > ;
< ItemTemplate >
< asp:DropDownList ID = DropDownList1 runat = server AppendDataBoundItems = < span class =code-keyword> true >
< asp:ListItem = - 1 > - 选择评分 - < / asp:ListItem >
< / asp:DropDownList >
< / ItemTemplate >
< / asp:TemplateField >


< span class =code-keyword>< asp:TemplateField HeaderText = 他的演讲中是否响亮而清晰 >
< ItemTemplate >
< asp:DropDownList ID = < span class =code-keyword> DropDow nList1 runat = server AppendDataBoundItems = true >
< asp:ListItem = - 1 > - 选择评分 - < / asp:ListItem < span class =code-keyword>>
< / asp:DropDownList >
< span class =code-keyword>< / ItemTemplate >
< / asp:TemplateField >



















在标签容器中的运行模式下如下



教员

当我点击标签容器中的教员我想要显示gridview。





用于显示tab容器中的gridview内容我写了如下代码



protected void Page_Load(object sender,EventArgs e)

{

if(!IsPostBack)

{

试试

{

Facultybindgrid ();

}

catch

{



}

} < br $>
}



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;

}



但是当我运行并点击标签容器中的教师时,gridview没有显示。



请帮助我。从上面的代码中我犯了什么错误。



问候

Jegan B

解决方案

您还没有在GridView中定义列,通过将 AutoGenerateColumns 设置为false将阻止自动生成列LY。最后你不会看到任何记录。

set AutoGenerateColumns =true

< asp:GridView id =gvfacultyrunat =serverbackcolor =LightGoldenrodYellowBorderColor =Tanwidth =91px autogeneratecolumns =true ForeColor =Black > 


My source page code as follows

<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

解决方案

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">


这篇关于在gridview中的ajax选项卡容器中显示asp.net中的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆