运行网站时,数据不会在GridView中填充 [英] Data not Populating in GridView when Running the Website

查看:54
本文介绍了运行网站时,数据不会在GridView中填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个网站,我正在尝试在网格视图中选择数据。

查询正在运行并在visual studio中显示结果。

当我运行网站时,网格视图不会显示。

I''m creating a web site and I''m trying to select data in a grid view.
The query is working and show me the result in the visual studio.
When I run the website the grid view does not display.

<![CDATA[<%@ Page Title="" Language="C#" MasterPageFile="~/DrMasterPage.master" AutoEventWireup="true" CodeFile="DrHome.aspx.cs" Inherits="DrHome" %>

<asp:content id="Content1" contentplaceholderid="head" runat="Server" xmlns:asp="#unknown">
</asp:content>
<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="Server" xmlns:asp="#unknown">
</asp:content>
<asp:content id="Content3" contentplaceholderid="ContentPlaceHolder2" runat="Server" xmlns:asp="#unknown">

    <asp:dropdownlist id="DropDownList1" runat="server">
        DataSourceID="SqlDataSource1" DataTextField="Faculty_Name"
        DataValueField="Faculty_ID" AutoPostBack="True">
    </asp:dropdownlist>

    <br />
    <br />
    <asp:gridview id="GridView1" runat="server" autogeneratecolumns="False">
        DataSourceID="SqlDataSource2">
        <columns>
            <asp:boundfield datafield="Room_Name" headertext="Room_Name">
                SortExpression="Room_Name" />
            <asp:boundfield datafield="Group_Name" headertext="Group_Name">
                SortExpression="Group_Name" />
            <asp:boundfield datafield="Course_Name" headertext="Course_Name">
                SortExpression="Course_Name" />
            <asp:boundfield datafield="Day" headertext="Day" sortexpression="Day" />
            <asp:boundfield datafield="StartTime" headertext="StartTime">
                SortExpression="StartTime" />
            <asp:boundfield datafield="EndTime" headertext="EndTime">
                SortExpression="EndTime" />
        </asp:boundfield></asp:boundfield></asp:boundfield></asp:boundfield></asp:boundfield></columns>
    </asp:gridview>
    <asp:sqldatasource id="SqlDataSource2" runat="server">
        ConnectionString="<%$ ConnectionStrings:Graduation_ProjectConnectionString %>" SelectCommand="
Select  Room.Room_Name ,  Grooup.Group_Name , Course.Course_Name ,
        AssociatedTimeSlot.Day ,AssociatedTimeSlot.StartTime ,
         AssociatedTimeSlot.EndTime

From   Grooup,Course,Room,AssociatedTimeSlot,Assignment,Professor,Faculty,Professor_Faculty
where
Grooup.Group_ID= Assignment.Group_ID
 and
 Course.Course_ID=Assignment.Course_ID
and
 Room.Room_ID =Assignment.Room_ID
 and
Assignment.Slot_ID =  AssociatedTimeSlot.Slot_ID

and
Faculty.Faculty_ID=Professor_Faculty.Facu_ID
and
Professor_Faculty.Prof_ID=@Prof_Id
and
Assignment.Professor_Faculty_ID=@Prof_Id
">
        <SelectParameters>
            <asp:sessionparameter name="Prof_Id" sessionfield="DrID" />
        </SelectParameters>
    </asp:sqldatasource>

    <br />

    <br />

    <asp:sqldatasource id="SqlDataSource1" runat="server">


        ConnectionString="<%$ ConnectionStrings:Graduation_ProjectConnectionString %>" SelectCommand="select Faculty.Faculty_Name,Faculty.Faculty_ID

from faculty , Professor , Professor_Faculty

where Faculty.Faculty_ID=Professor_Faculty.Facu_ID
and
Professor.Professor_ID=Professor_Faculty.Prof_ID
and
Professor.Professor_ID=@Prof_Id


">
        <SelectParameters>
            <asp:sessionparameter name="Prof_Id" sessionfield="DrId" />
        </SelectParameters>
    </asp:sqldatasource>
</asp:content

>

推荐答案

ConnectionStrings:Graduation_ProjectConnectionString%>SelectCommand =
选择Room.Room_Name,Grooup.Group_Name,Course.Course_Name,
AssociatedTimeSlot.Day,AssociatedTimeSlot.StartTime,
AssociatedTimeSlot.EndTime

来自Grooup,课程,会议室,AssociatedTimeSlot,作业,教授,学院,教授_Faculty
其中
Grooup.Group_ID = Assignment.Group_ID

课程.Course_ID = Assignment.Course_ID

Room.Room_ID = Assignment.Room_ID

Assignment.Slot_ID = AssociatedTimeSlot.Slot_ID


Faculty.Faculty_ID = Professor_Faculty.Facu_ID

Professor_Faculty.Prof_ID=@Prof_Id

Assignment.Professor_Faculty_ID=@Prof_I d
>
< SelectParameters >
< asp:sessionparameter 名称 = Prof_Id < span class =code-attribute> sessionfield = DrID / > ;
< / SelectParameters >
< / asp:sqldatasource >

< br / >

< br / >

< asp:sqldatasource < span class =code-attribute> id = SqlDataSource1 runat = 服务器 >


ConnectionString =<%
ConnectionStrings:Graduation_ProjectConnectionString %>" SelectCommand=" Select Room.Room_Name , Grooup.Group_Name , Course.Course_Name , AssociatedTimeSlot.Day ,AssociatedTimeSlot.StartTime , AssociatedTimeSlot.EndTime From Grooup,Course,Room,AssociatedTimeSlot,Assignment,Professor,Faculty,Professor_Faculty where Grooup.Group_ID= Assignment.Group_ID and Course.Course_ID=Assignment.Course_ID and Room.Room_ID =Assignment.Room_ID and Assignment.Slot_ID = AssociatedTimeSlot.Slot_ID and Faculty.Faculty_ID=Professor_Faculty.Facu_ID and Professor_Faculty.Prof_ID=@Prof_Id and Assignment.Professor_Faculty_ID=@Prof_Id "> <SelectParameters> <asp:sessionparameter name="Prof_Id" sessionfield="DrID" /> </SelectParameters> </asp:sqldatasource> <br /> <br /> <asp:sqldatasource id="SqlDataSource1" runat="server"> ConnectionString="<%


ConnectionStrings:Graduation _ProjectConnectionString%> SelectCommand =选择Faculty.Faculty_Name,Faculty.Faculty_ID

来自教师,教授,教授_Faculty

其中Faculty.Faculty_ID = Professor_Faculty.Facu_ID

Professor.Professor_ID = Professor_Faculty.Prof_ID

Professor.Professor_ID=@Prof_Id


>
< SelectParameters >
< asp:sessionparameter 名称 = Prof_Id < span class =code-attribute> sessionfield = DrId / > ;
< / SelectParameters >
< / asp:sqldatasource >
< / asp:content

>
ConnectionStrings:Graduation_ProjectConnectionString %>" SelectCommand="select Faculty.Faculty_Name,Faculty.Faculty_ID from faculty , Professor , Professor_Faculty where Faculty.Faculty_ID=Professor_Faculty.Facu_ID and Professor.Professor_ID=Professor_Faculty.Prof_ID and Professor.Professor_ID=@Prof_Id "> <SelectParameters> <asp:sessionparameter name="Prof_Id" sessionfield="DrId" /> </SelectParameters> </asp:sqldatasource> </asp:content >


这篇关于运行网站时,数据不会在GridView中填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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