简体   繁体   English

如何在按钮上单击数据列表中的数据列表中检索值

[英]how to retrieve a value in datalist on the button click in DataList

We have a Datalist in which we have some data, with every Item we have a button control. 我们有一个数据列表,其中有一些数据,每个项目都有一个按钮控件。 What I want to achieve is that on the button click, the data related to that particular row of Datalist is fetched whose Button control is clicked. 我要实现的是,在单击按钮时,将获取与单击“按钮”控件的“数据列表”特定行相关的数据。 How to accomplish this? 如何做到这一点? The problem is how to attach the button control with values related in that particular row? 问题是如何将按钮控件附加到与该特定行相关的值? Note that I am using ArrayList as the Datasource since I am enabling padding via pageDataSource class... 请注意,由于我通过pageDataSource类启用填充,因此我将ArrayList用作数据源。

Implement the OnDataBinding event for the Button . 实现ButtonOnDataBinding事件。 Then in the Button set the CommandArgument to something that will identify the row you are clicking. 然后在“ Button中将CommandArgument设置为将标识您要单击的行的内容。 Then implement the OnItemCommand event for the DataList . 然后为DataList实现OnItemCommand事件。 You will be able to read the CommandArgument for the Button that was clicked and then perform whatever action you need. 您将能够读取所单击ButtonCommandArgument ,然后执行所需的任何操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM