Reputation: 4915
I can get the the first row in a ListView item in .NET 3.5 by:
ListViewDataItem theFirstItem = ListView1.Items[0];
But then how do I get the get the value of the item's CommandArgument ( an int)
< %# Eval("PKey") %>
in the aspx.
Or get the contents of
<asp:Label ID="lblStatus" runat="server" Text= '<%# Eval("Status") % />
Upvotes: 0
Views: 3976
Reputation: 4915
Thanks mgroves!
Got the value of the command argument by:
ListViewDataItem item = ListView1.Items[0];
Button btnRead = (Button)item.FindControl("btnRead");
int pkey = int.Parse( btnRead.CommandArgument) ;
I should have asked sooner!
Upvotes: 0
Reputation: 26096
Does FindControl work for ListView items?
ListViewDataItem theFirstItem = ListView1.Items[0];
Label lblStatus = (Label)theFirstItem.FindControl("lblStatus")
Response.Write(lblStatus.Text); // outputs the text of that label
Upvotes: 2