且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在ListView.ItemCommand事件中获取控件值?

更新时间:2023-10-13 19:49:10

First of all your Labels Text property should be declared...



Instead of...

First of all your Labels Text property should be declared...

Instead of...
<asp:Label runat="server" ID="lblID"> <%# Eval("JobID") %> </asp:Label>



Do like...


Do like...

<asp:Label runat="server" ID="lblID" Text='<%# Eval("JobID") %>'></asp:Label>



Then inside the ItemCommand Event, you can code like below to get the Control.


Then inside the ItemCommand Event, you can code like below to get the Control.

Label LabelEmail = (Label)e.Item.FindControl("lblID");