禁用在页面加载时运行SQLDataSource [英] Disable running a SQLDataSource on page load

查看:113
本文介绍了禁用在页面加载时运行SQLDataSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

祝大家有美好的一天.

我希望有人可以对我在ASP.NET页上遇到的问题提出建议.

我在页面上有2个SQLDataSource对象,并且都通过向导设置了它们的参数;但是,我只想运行一个或另一个依赖于Session对象中的值.

可悲的是,两个SQL对象都运行,这会降低页面的呈现效果,尤其是在移至数据网格中的下一页时.

有什么办法可以防止一个或另一个对象在页面加载事件中执行它的操作.

任何提示,技巧将不胜感激.

F

Good day to you all.

I am hoping someone could give a suggestion to a problem I am having on a ASP.NET page.

I have 2 SQLDataSource object on the page and both have their parameters set via the Wizard; however, I would like to run only one or the other dependent upon a value in a Session object.

Sadly, both SQL objects run which degrades page rendering, especially when moving to a next page in a data grid.

Is there any way that I could prevent one or the other object from performing it''s operation in the page load event.

Any hints, tricks will be greatly appreciated.

F

推荐答案

没有技巧.您完全可以控制自己的代码.您只需要离开向导并自己学习即可.

There is no trick to it. You are in complete control of your code. You just need to step away from the Wizard and learn to do it yourself.

if(Session["Foo"] == "some value")
{
   myControl.DataSource = myDataSource1;
}
else
{
   myControl.DataSource = myDataSource2;
}


严酷但真实的标记.非常感谢您的宝贵时间.我意识到,对于这种特定的安装,我必须让向导退出.再次感谢您进入我的脑海.

F
Harsh but true Mark. Thank you very much for your time. I realized that for this particular installation I have to let the Wizard go. Again, thanks for getting into my head.

F


这篇关于禁用在页面加载时运行SQLDataSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆