0

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") % /> 

2 Answers 2

2

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 
Sign up to request clarification or add additional context in comments.

Comments

0

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!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.