I have a Listview named "listview1". I am displaying students name in the list view.
I got collection of students Id and name in a data table.
// appending the students name in the listview
foreach (DataRow dr in dtStudentInfo.Rows)
{
Item = listView1.Items.Add(dr["strName"].ToString());
Item.Tag = dr["nId"].ToString();
}
question : How can i get name of the student if i know the student Id?
Eg: For the student Id 5 i want to know the name of the student.
Here i can do this by getting whole item collection inside a for loop and
i can compare the tag. But i want a direct method where i can specify the tag as 5 and get
student name for the respective tag?
I have a Listview named "listview1". I am displaying students name in the list view. I got collecti...
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

subrahmanya6 reputationPosted Aug 13, 2012, 11:04 PM EDT
listView1.Items.Add("key", "Text", 0);
......................
.....................
listView1.Items.Find("key", true) returns array of items
sarin s18 reputationPosted Aug 14, 2012, 2:24 AM EDT