Hi friends,
I have a list view which contains an id and a name.... upon selecting one row i should be able to view the details of that particular row.. i.e name, age, salary etc...Im using Visual studio .net 2003 and sql server 2005..

Recommended Answers

All 3 Replies

In the selected index change or one of the click events of the list you should put.

dim strLine as strin 
strLine = List1.SelectedItem.Text

That will get you the line, from there you will need to do string splits & string manipulation on your data.

What is string split and how do we do it?

String splits allow you to easily retrieve values in a string. Lets say that the line that was read from the listview has been formated by putting a tab between the values. You would get the data like this;

'declare an array to hold the vals
dim listVals as String() = Nothing

'get the line from the list
strLine = List1.SelectedItem.Text

'get the vals from the string
listVals = strLine.Split(vbTab)

If the line wasn't formatted with tabs as it was added to the listview then you may have to use left, mid and right string functions.

Microsoft.VisualBasic.Right(string, length)
Microsoft.VisualBasic.Left(string, length)
Microsoft.VisualBasic.Mid(string, start pos, length)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.