Sou*_*ceC 1 asp.net data-binding gridview sqldatasource
如果我将GridView(通过DataSourceID属性)绑定到SqlDataSource并设置SelectCommand和UpdateCommand属性,那么一切都很完美.
但我注意到,如果我,无论出于何种原因,还在Page_Load()中手动调用DataBind(),那么SqlDataSource不执行任何更新,即使当GridView的Update按钮是SqlDataSource.Updating和SqlDataSource.Updated事件时也会触发点击.
有人可以解释为什么不发生更新?
这是因为在激活SqlDataSource.Updating和SqlDataSource.Updated事件之前会触发Page_Load.这意味着GridView会重置为用户编辑之前的状态.
有关详细信息,请查看Page Lifecycle文档.SqlDataSource.Updating和SqlDataSource.Updated事件发生在Postback事件处理部分中.
| 归档时间: |
|
| 查看次数: |
4997 次 |
| 最近记录: |