gpt4 book ai didi

asp.net - 什么时候应该使用 Page.DataBind() 与 Control.DataBind()?

转载 作者:行者123 更新时间:2023-12-03 12:44:03 31 4
gpt4 key购买 nike

在 ASP.NET 中,您可以单独绑定(bind)控件(即 GridView1.DataBind() ),也可以调用 Page.DataBind()绑定(bind)页面上的所有控件。

这两个调用之间有什么具体区别吗?有没有时候一个人应该比另一个人更受欢迎?

最佳答案

Page.DataBind() 之间进行选择与 Control.DataBind() 相比, 这里是微软 guidance :

"Both methods work similarly. The main difference is that all data sources are bound to their server controls after the Page.DataBind method is called. No data is rendered to the control until you explicitly call either the DataBind method of the Web server control or until you invoke the page-level Page.DataBind method. Typically, Page.DataBind (or DataBind) is called from the Page_Load event."



在某些情况下,您需要单独指定控件数据绑定(bind),具体取决于当前页面方案。对于绑定(bind)哪些控件以及何时绑定(bind)控件的详细控制级别,我选择控制级别 DataBind()方法。

关于asp.net - 什么时候应该使用 Page.DataBind() 与 Control.DataBind()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1603398/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com