Tyler Treat
Tyler Treat

Reputation: 15008

Accessing current item from ListView data source

I figured this wouldn't be too difficult to do, but I can't seem to figure out how to do it. Is there a way to easily access the current item from a ListView data source? For instance, you can easily evaluate the current item's properties using Eval("propertyName"), but is there a way to access the object itself?

And if this isn't possible, what I ultimately want to do is get the Type of the object.

Upvotes: 0

Views: 998

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94643

Use FindControl Method.

For example,

int index=0; // obtain the index of an item. 
TextBox num = (TextBox)ListView1.Items[index].FindControl("numTextBox");

Upvotes: 1

Related Questions