让 Gridview 从 Session 读取 ConnectionString?
如何让我的SQLDataSource
从会话变量中读取ConnectionString
?
我知道我可以用代码做到这一点,如下所示:
protected void Page_Load(object sender, EventArgs e)
{
uxDS.ConnectionString = Session["con"].ToString();
}
但是我真的想要这样的东西吗?
<asp:SqlDataSource ID="uxDS" ... ConnectionString='<% Session["con"] %>' />
我可以发誓我在某个地方看到过它,但我似乎找不到它。
How can get my SQLDataSource
to read the ConnectionString
from a session variable?
I know I can do it in code, like this:
protected void Page_Load(object sender, EventArgs e)
{
uxDS.ConnectionString = Session["con"].ToString();
}
But what I really want is something like this?
<asp:SqlDataSource ID="uxDS" ... ConnectionString='<% Session["con"] %>' />
I could have sworn I saw it done somewhere but I can't seem to find it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你试过这个吗?
Have you tried this?