views:

162

answers:

2

I can get the the first row in a ListView item in c# aspnet 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") %>

+1  A: 

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
mgroves
A: 

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!

Lill Lansey