ASP.NET从ListView获取Selected List项数据 [英] ASP.NET Get the Selected List item data from ListView

查看:101
本文介绍了ASP.NET从ListView获取Selected List项数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET Listview,它由Datatable填充。



I have ASP.NET Listview which is populated by a Datatable.

<asp:ListView ID="lvCustomers" runat="server" GroupPlaceholderID="groupPlaceHolder1"
                                                    ItemPlaceholderID="itemPlaceHolder1" OnPagePropertiesChanging="lvCustomers_PagePropertiesChanging" ClientIDMode="AutoID">





在页面的正文中,我打印出表中的值:





In the page's body I have printed out the values from the table:

<asp:Label ID="idlbl" runat="server" Visible="false" Text='<%# Eval("id") %>'></asp:Label>
<h4 class="timeline-title"><%# Eval("ActivityContent") %></h4>





在后面的代码中,我需要通过按钮单击事件将标签'idlbl'的值作为String获取。我该怎么做?



In the code behind, I need to get the value of label 'idlbl' as a String through a button click event. How do I do this?

推荐答案

引用:

在后面的代码中,我需要通过按钮单击事件将标签'idlbl'的值作为String获取。我该怎么做?

In the code behind, I need to get the value of label 'idlbl' as a String through a button click event. How do I do this?

如果Button在ListView之外,那么你需要遍历ListView的项目并在循环中获取。



如果Button在里面,那么你可以使用 ListView.ItemCommand事件 [ ^ ]并找到当前项目及其属性。

If the Button is outside of ListView, then you need to loop through the Items of ListView and fetch inside the loop.

If the Button is inside, then you can use ListView.ItemCommand Event[^] and find the current item and its properties.


这篇关于ASP.NET从ListView获取Selected List项数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆