</asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:gfsConnectionString %>"
            SelectCommand="SELECT score.s_pom, score.s_score, class.c_name, score.s_reason, score.s_date, score.st_num FROM class INNER JOIN score ON class.c_id = score.c_id WHERE (score.st_num =N'<%$=num%>' ) ORDER BY score.s_pom, score.s_date DESC">
        </asp:SqlDataSource>
红颜色的num在程序里是这样定义的:
string num = Session["UserName"].ToString();但是还是查不出来,num的值没传进去,请高手指点.

解决方案 »

  1.   

    </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=" <%$ ConnectionStrings:gfsConnectionString %>" 
                SelectCommand="SELECT score.s_pom, score.s_score, class.c_name, score.s_reason, score.s_date, score.st_num FROM class INNER JOIN score ON class.c_id = score.c_id WHERE (score.st_num ='@Number' ) ORDER BY score.s_pom, score.s_date DESC">
            <SelectParameters>
                <asp:Parameter Name="Number" />
            </SelectParameters> 
            </asp:SqlDataSource> //在 .cs中给SqlDataSource1加上Selecting事件
      protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
              //如果取得在值放在Number中
              e.Command.Parameters["@Number"]=Number;
        }
      

  2.   

    </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=" <%$ ConnectionStrings:gfsConnectionString %>" 
                SelectCommand="SELECT score.s_pom, score.s_score, class.c_name, score.s_reason, score.s_date, score.st_num FROM class INNER JOIN score ON class.c_id = score.c_id WHERE (score.st_num ='@Number' ) ORDER BY score.s_pom, score.s_date DESC"> 
            <SelectParameters> 
                <asp:Parameter Name="Number" /> 
            </SelectParameters> 
            </asp:SqlDataSource> //在 .cs中给SqlDataSource1加上Selecting事件 
      protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e) 
        { 
              //如果取得在值放在Number中 
              e.Command.Parameters["@Number"]=Session["UserName"].ToString();  //在这里可以断点一下,看看Session["UserName"]是否正确
        } 
      

  3.   

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=" <%$ ConnectionStrings:gfsConnectionString %>" SelectCommand="SELECT score.s_pom, score.s_score, class.c_name, score.s_reason, score.s_date, score.st_num FROM class INNER JOIN score ON class.c_id = score.c_id WHERE (score.st_num = @number) ORDER BY score.s_pom, score.s_date DESC"> 
    <SelectParameters>
         <asp:SessionParameter Name="number" SessionField="UserName" />
    </SelectParameters>