双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

求助,C#GridView无法显示

规定昵称 规定昵称 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

     后台

           SqlConnection key = new SqlConnection (ConfigurationManager.ConnectionStrings["blogConnectionString"].ConnectionString);
            key.Open ();
            SqlDataAdapter username = new SqlDataAdapter ("select * from UserRegistry where name = '" + "张三" + "'and password = '" + "zhangsan" + "'", key);
            DataSet user = new DataSet ();
            username.Fill (user, "user");
            key.Close ();
            Session["user"] = user;

前台:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="470px">
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:blogConnectionString %>" SelectCommand="SELECT * FROM [post] WHERE ([publisherID] = @publisherID)">
            <SelectParameters>
                <asp:SessionParameter Name="publisherID" SessionField="(DataSet)Sessoin.Tables[&quot;user&quot;].Rows[0][0]" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:blogConnectionString %>" SelectCommand="SELECT * FROM [reply] WHERE ([publisherID] = @publisherID)">
            <SelectParameters>
                <asp:SessionParameter Name="publisherID" SessionField="(DataSet)Session.Tables[&quot;user&quot;].Rows[0][2]" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>

数据源绑定上了,测试查询也能查到,代码也没报错,各位大佬能解释一下么,本人是个菜鸡,虐的轻一点

...全文
评论 2
收藏 已收藏
分享
返回顶部
规定昵称
C# 111,129 成员 642,540 内容