【发布时间】:2011-08-28 06:50:21
【问题描述】:
我正在尝试使用基于参数化输入的 SQL 数据源填充数据表。棘手的是参数化输入的值仅在后面的代码中可用,因此我不得不在代码中编写 SQL 数据源后台
我该怎么做(我使用的是 C# 和 ASP.Net 4.0)
当前asp.net页面中创建sql数据源连接的代码是:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:LicensingConnectionString %>"
SelectCommand="SELECT * FROM [commissions] where username=@username "></asp:SqlDataSource>
我想在@username中使用的值是在这段代码后面的代码中检索到的
IPrincipal p = HttpContext.Current.User;
// p.Identity.Name : this is what we will use to call the stored procedure to get the data and populate it
string username = p.Identity.Name;
谢谢!
【问题讨论】:
标签: c# asp.net entity-framework-4 sqldatasource