sarin s

sarin s

  • NA
  • 18
  • 17.7k

I have a Listview named "listview1". I am displaying students name in the list view. I got collecti...

Aug 14 2012 2:28 AM

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?

Answers (2)