如何取消绑定ObjectDataSource?
CheckPara 是我的 OnDataBinding 过程
SqlDataSource1 是 ObjectDataSource (这只是令人困惑的名称)
语言是 Nemerle,但如果您了解 C#,您可以轻松阅读它,
protected virtual CheckPara(_ : object, _ : System.EventArgs) : void
{
foreach(x is Parameter in SqlDataSource1.SelectParameters)
when(x.DefaultValue=="") //Cancel binding
}
那么当没有完全配置的 ObjectDataSource 时,如何取消绑定?
或者...如何仅在完成所有参数后才运行绑定?
CheckPara is my OnDataBinding procedure
SqlDataSource1 is ObjectDataSource (it's only confusing name)
Language is Nemerle, but if you know C# you can read it easy
protected virtual CheckPara(_ : object, _ : System.EventArgs) : void
{
foreach(x is Parameter in SqlDataSource1.SelectParameters)
when(x.DefaultValue=="") //Cancel binding
}
so how can I cancel binding when there is not fully configurated ObjectDataSource ?
Or... how can I run binding only when I done with all parameters ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 ObjectDataSource 的 Selecting 事件,放置 select 的 for 循环,如果您想取消绑定它,请使用 e.Cacnel = true 即可完成!
Use ObjectDataSource's Selecting event, place your for loop of select and if you want to cancel binding it, use e.Cacnel = true and you are done!!
ASP.NET 默认情况下不绑定。您必须调用
DataBind
。调用Page.DataBind
将调用所有控件的DataBind
方法。因此,只需在准备好后调用控件的DataBind
即可。使用ObjectDataSource
时,我通常不会调用Page.DataBind
。如果您在 Web 窗体 (aspx) 页中声明了
ObjectDataSource
,则在Page.Load
事件之后立即调用该控件的DataBind
方法并且在控件的Load
事件之前。ObjectCreating
和ObjectCreated
事件可能对您有帮助。以下是设置业务对象的连接字符串的示例。ASP.NET does not bind by default. You must call
DataBind
. CallingPage.DataBind
will call all control'sDataBind
method. Therefore, just call your control'sDataBind
when ready. I usually do not callPage.DataBind
when using anObjectDataSource
.If you have declared an
ObjectDataSource
in your Web Form (aspx) page, then the control'sDataBind
method is called immediately after thePage.Load
event and before the control'sLoad
event. TheObjectCreating
andObjectCreated
events may be of help to you. Following is a sample that sets the business object's connection string.