<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:FlowServerConnectionString %>"
SelectCommand="SELECT [RepGroup_Name], [RepGroup_ID] FROM [Rep_Group] WHERE [RepGroup_ID] in
(SELECT [ID_RepGroup]
FROM [FlowServer].[dbo].[Rep_Permission]
WHERE [ID_User]=@ID_User)">
<SelectParameters>
<asp:ProfileParameter DefaultValue="" Name="ID_User" PropertyName="UserName" />
</SelectParameters>
如何将System.Web.HttpContext.Current.User.Identity.Name插入我的属性“ID_User”(这里是用户名)
答案 0 :(得分:2)
在您的SqlDataSource1上添加OnInit="SqlDataSource1_Init"
,然后将以下事件添加到后面的代码中:
protected void SqlDataSource1_Init(object sender, EventArgs e)
{
this.SqlDataSource1.SelectParameters["ID_User"].DefaultValue = System.Web.HttpContext.Current.User.Identity.Name;
}