Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting value from stored procedure

Status
Not open for further replies.

yonelay

Programmer
Jan 17, 2007
10
US
I have a sp that has firstname, lastname, fullname, and personid columns. In my C#, I have a drop down which displaymember is fullname and valuemember is personid. So far so good, I got those values. Now, I want firstname and lastname of the selected person from the dropdown. How do I do that? Someone suggested me to use Rows[0]["firstname"], but it only gave me the firstname and lastname of the first record displayed, not selected.

Can anyone please help me?
 
If I am right,on the selectedindexchanged event you can derive the text portion of the dropdown with the dropdown.selecteditem property.
 
try this, personid must be unique
string expression = "personid = dd.SelectedItem.value");
foundIndex = yourtable.Select(expression);
Rows[foundIndex]["firstname"]

Marty
 
syntax is wrong but I think you have the idea
should have been something like this
string expression = "personid = " + dd.SelectedItem.value;

Marty
 
Thanks for the answers.

Here is the respond I got from other post.

Rows[dropdownname.SelectedIndex]["firstname"]

 
I do not see how that could work unless the SelectedIndex is the same as your personid.

Marty
 
DataRow[] foundRows;
string expression = "personid = " + dd.SelectedItem.value;
//yourtable is the same table you used for your dd
foundRows = yourtable.Select(expression);
int foundIndex = foundRows[0][personid column name or position];
string firstName = yourtable.Rows[foundIndex]["firstname"];

I only have access to a command line and text editor so I won't test it.
Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top