Context.User.Identity.GetUserId()不返回任何值

时间:2014-07-19 08:23:02

标签: asp.net sql code-behind sqldatasource

为什么以下代码不会返回任何数据?数据库中有Context.User.Identity.GetUserId()

的值

ASPX标记:

<asp:SqlDataSource ID="owner_information" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT * FROM [Viewtest] WHERE [IDuser] = @IDowner">
    <SelectParameters>
        <asp:Parameter Name="IDowner" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

代码隐藏:

protected void Page_PreRender(object sender, EventArgs e)
{
    owner_information.SelectParameters["IDowner"].DefaultValue = Context.User.Identity.GetUserId();  
}

0 个答案:

没有答案