1 回答
TA贡献1802条经验 获得超6个赞
您可以尝试以下方法:添加 SelectParameter 和 OnSelecting 事件处理程序。在 OnSelecting 事件处理程序后面的代码中设置 UserId 参数
<asp:SqlDataSource ID="ReadReviewDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:Labor32_ECConnectionString %>"
SelectCommand="SELECT sites.name
FROM sites
INNER JOIN reviews ON sites.id = reviews.site_id
WHERE reviews.usr_id = @UserId"
OnSelecting="ReadReviewDataSource_Selecting">
<SelectParameters>
<asp:Parameter Name="UserId" />
</SelectParameters>
</asp:SqlDataSource>
背后的代码:
protected void ReadReviewDataSource_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
e.Command.Parameters["@UserId"].Value = ConfigurationManager.AppSettings["TestUserID"];
}
- 1 回答
- 0 关注
- 190 浏览
添加回答
举报