DataList的问题 - ItemCommand事件不响应
2007-07-02 08:05
218 查看
以前都没有用过datalist,今天用的时候就发现了一个问题,在这里记录下来!
The itemcommand event for the datalist will not fire if you rebind
the DataList control everytime the page loads. This event will fire if you
use the viewstate information when the page gets loaded. The reason is that
if you do not use the view state information the control gets new set of
data and it may not be the same data that you were working on before when
you selected any items in the DataList.
E.g. In the following scenario the Itemcommand event will not fire because
the datalist is populated with new data.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11)
..
DataList1.DataBind()
End Sub
But it will fire in this case because we are using viewstate data.
======================
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
SqlDataAdapter1.Fill(DataSet11)
DataList1.DataBind()
End If
End Sub
Hope this helps.
The itemcommand event for the datalist will not fire if you rebind
the DataList control everytime the page loads. This event will fire if you
use the viewstate information when the page gets loaded. The reason is that
if you do not use the view state information the control gets new set of
data and it may not be the same data that you were working on before when
you selected any items in the DataList.
E.g. In the following scenario the Itemcommand event will not fire because
the datalist is populated with new data.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11)
..
DataList1.DataBind()
End Sub
But it will fire in this case because we are using viewstate data.
======================
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
SqlDataAdapter1.Fill(DataSet11)
DataList1.DataBind()
End If
End Sub
Hope this helps.
相关文章推荐
- 关于DataList的嵌套 和(ItemCommand)事件的问题
- 刚刚发现的一个小问题的解决办法(datalist绑定和itemcommand)
- GridView设置Item高度,解决第一个item显示不正常以及事件不响应的问题
- ListView的item点击事件不响应(你觉得应该响应的,但是就是没响应,而且不是代码问题)
- 解决listView的item无法响应点击事件onItemClickListener的问题
- 解决listview item Textview加超链接 超链接以外部分不响应listview item点击事件问题
- DataList Web--OnItemCommand 事件
- Android--焦点问题-ListView中item及其子控件无法响应点击事件
- 点击ListView中item时,出现不能及时响应点击事件的问题
- Repeater 为什么不激发 ItemCommand事件了?
- ListView应用------ListView控件显示List集合中的数据,并对Item响应选择事件(法一)
- listView嵌套button或者其它clickable控件时会出现listView的onitemClick事件不响应的问题
- iOS开发之隐藏tabbar--解决隐藏后依然不能响应对应位置事件的问题
- 点击事件不响应的问题
- WPF: 在 MVVM 设计中实现对 ListViewItem 双击事件的响应
- Asp.net 2.0自定义控件(点击HyperLink后执行事件)[网友问题: DataList里HyperLink控件激发事件,在哪定义?]
- android ListView Item和CheckBox、Button点击事件冲突的问题
- WPF: 在 MVVM 设计中实现对 ListViewItem 双击事件的响应
- 【Android疑难杂症】GridView动态设置Item的宽高导致第一个Item不响应或显示不正常的问题
- gridview 中模板列无法响应row_command事件