</body> </html>SelectCommand="SELECT ID,Subject FROM Mail WHERE (Dispose = 1 or Dispose = 2 or Dispose = 3)">我要在这后面加上 and Subject=Session["UserId"]. 你看如何达到这个效果?
SelectCommand="SELECT ID,Subject FROM Mail WHERE (Dispose = 1 or Dispose = 2 or Dispose = 3) and Subject='"+<%= Session["UserId"].ToString()%>+"'">
SelectCommand="SELECT ID,Subject FROM Mail WHERE (Dispose = 1 or Dispose = 2 or Dispose = 3) and Subject='"+<%= Session["UserId"].ToString()%>+"'">
直接出错.怎么办?
换成这样 <asp:SqlDataSource ID="MailSearch" runat="server" ConnectionString="<%$ ConnectionStrings:AdsystemConnectionString %>" SelectCommand="SELECT ID,Subject FROM Mail WHERE (Dispose = 1 or Dispose = 2 or Dispose = 3) and Subject=@UserId"> <SelectParameters> <asp:SessionParameter Name="UserId" SessionField="UserId" /> </SelectParameters> </asp:SqlDataSource>
SelectCommand="select * from abc WHERE (name='"+Session["name"].Tostring()+"')"
是这样吗?如果是的话,那也是不行的.
貌似在这里它好像不认识这个Session["name"]一样.
SelectCommand="select * from abc WHERE name=System.Web.HttpContext.Current.Session["name"].Tostring()"这样吗?
也不行哦.
我这是在aspx里做的,不是在aspx.cs里面做的.
右键没有"引用".
我是菜菜鸟,请说得列具体点,谢谢!
aspx页面里<%=ss%>
下面这段是aspx里面的,你看看.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="IndexRight.aspx.cs" Inherits="IndexRight" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>收取邮件</title>
<link href="CSSMan.css" rel="stylesheet" type="text/css" />
<link href="CSSIndex.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<%--<div class="roleheader"><span>邮件信息</span> </div>--%>
<br />
<asp:Label ID="Label22" runat="server" Font-Size="12px" ForeColor="#FF9900"
Text="<邮件列表>"></asp:Label>
<br />
<br />
<div style=" overflow: auto; height: 480px; width: 800px;">
<asp:GridView ID="MailData" AutoGenerateColumns="False" runat="server"
CssClass="gridView1" PageSize="20" DataSourceID="MailSearch" >
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="chkall" runat="server" AutoPostBack="True" Text="全选" OnCheckedChanged="Check_Click" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" Text="优先处理" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" HeaderText="序号" />
<asp:BoundField DataField="Subject" HeaderText="流程主题" />
</Columns>
<PagerSettings FirstPageText="首页" LastPageText="末页" Mode="NumericFirstLast" PageButtonCount="5" />
</asp:GridView>
</div>
</div>
<asp:SqlDataSource ID="MailSearch" runat="server" ConnectionString="<%$ ConnectionStrings:AdsystemConnectionString %>"
SelectCommand="SELECT ID,Subject FROM Mail WHERE (Dispose = 1 or Dispose = 2 or Dispose = 3)">
</asp:SqlDataSource>
<br />
<br />
<asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Size="Small"
ForeColor="#006699" Height="26px" Text="业务处理" /> </form>
</body>
</html>SelectCommand="SELECT ID,Subject FROM Mail WHERE (Dispose = 1 or Dispose = 2 or Dispose = 3)">我要在这后面加上 and Subject=Session["UserId"].
你看如何达到这个效果?
直接出错.怎么办?
<asp:SqlDataSource ID="MailSearch" runat="server" ConnectionString="<%$ ConnectionStrings:AdsystemConnectionString %>"
SelectCommand="SELECT ID,Subject FROM Mail WHERE (Dispose = 1 or Dispose = 2 or Dispose = 3) and Subject=@UserId">
<SelectParameters>
<asp:SessionParameter Name="UserId" SessionField="UserId" />
</SelectParameters>
</asp:SqlDataSource>
现在情况有点改善,单独运行IndexRight.aspx此页面没问题,不报错.
如果运行Index.aspx或发布运行时,还是和昨天一样报错.
怎么办?请指教,我的全部希望都寄托在你身上了.