Click here to Skip to main content
16,011,611 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I get Combobox Selected ValueMember Pin
Martin#24-Jan-07 22:31
Martin#24-Jan-07 22:31 
AnswerRe: How can I get Combobox Selected ValueMember Pin
quiteSmart24-Jan-07 22:29
quiteSmart24-Jan-07 22:29 
GeneralRe: How can I get Combobox Selected ValueMember Pin
dataminers24-Jan-07 22:47
dataminers24-Jan-07 22:47 
GeneralRe: How can I get Combobox Selected ValueMember Pin
dataminers24-Jan-07 22:59
dataminers24-Jan-07 22:59 
GeneralRe: How can I get Combobox Selected ValueMember Pin
{ ZuhaiB }™25-Jan-07 1:57
{ ZuhaiB }™25-Jan-07 1:57 
GeneralRe: How can I get Combobox Selected ValueMember Pin
dataminers25-Jan-07 2:13
dataminers25-Jan-07 2:13 
GeneralRe: How can I get Combobox Selected ValueMember Pin
{ ZuhaiB }™25-Jan-07 2:39
{ ZuhaiB }™25-Jan-07 2:39 
GeneralRe: How can I get Combobox Selected ValueMember Pin
dataminers25-Jan-07 3:46
dataminers25-Jan-07 3:46 
Dear Sirs,

I use Visual Studio .NET 2005 (Framework 2.0)

I use Tree-Tier architecture approach in my project, and I use NHibernate.
I get data in the Data Layer from database and initialize object.

In View Layer;
First of all I determine ValueMember and DisplayMember for ComboBox
comboBox1.ValueMember = "id";
comboBox1.DisplayMember = "name";

And determine DataSource for ComboBox. I get data in IList fromat from Data Layer.
comboBox1.DataSource = XYZ; //XYZ is a IList

Now, ComboBox list name, its OK. My problem is I get id when I select any name from combobox.



**FOR EXAMPLE:

TEST_TABLE

ID Name Surname
-- ---- -------
3 Jack Black
4 Marry Green
5 John Wall


I fill combobox like this;
comboBox1.ValueMember = "id";
comboBox1.DisplayMember = "name";
comboBox1.DataSource = obj; //obj is IList

So, combobox filled and show "Name"s.

How can I get selected value's ID from combobox.
For example, if I select "Marry" on the combobox, how can I get "4"?


Note: This ways not solve my problem.

Int32 i = Convert.ToInt32(comboBox1.SelectedValue);

Int32 i = (Int32)comboBox1.SelectedValue;

int i = (int)comboBox1.SelectedValue;

string test = (string)comboBox1.SelectedValue;

string deneme = comboBox1.SelectedItem.ToString();

object o = comboBox1.SelectedValue;

DataRowView o = (DataRowView) comboBox1.SelectedValue;


Best Regards...
QuestionmessageBox buttons related issue Pin
Saira Tanwir24-Jan-07 22:02
Saira Tanwir24-Jan-07 22:02 
AnswerRe: messageBox buttons related issue Pin
mihksoft24-Jan-07 22:08
mihksoft24-Jan-07 22:08 
AnswerRe: messageBox buttons related issue Pin
Parwej Ahamad24-Jan-07 22:15
professionalParwej Ahamad24-Jan-07 22:15 
GeneralRe: messageBox buttons related issue Pin
Martin#24-Jan-07 22:21
Martin#24-Jan-07 22:21 
AnswerRe: messageBox buttons related issue Pin
quiteSmart24-Jan-07 22:22
quiteSmart24-Jan-07 22:22 
GeneralRe: messageBox buttons related issue Pin
Martin#24-Jan-07 22:27
Martin#24-Jan-07 22:27 
GeneralRe: messageBox buttons related issue Pin
quiteSmart24-Jan-07 22:32
quiteSmart24-Jan-07 22:32 
GeneralRe: messageBox buttons related issue Pin
Martin#24-Jan-07 22:46
Martin#24-Jan-07 22:46 
GeneralRe: messageBox buttons related issue Pin
quiteSmart24-Jan-07 22:50
quiteSmart24-Jan-07 22:50 
GeneralRe: messageBox buttons related issue Pin
Martin#24-Jan-07 23:01
Martin#24-Jan-07 23:01 
GeneralRe: messageBox buttons related issue Pin
Seishin#25-Jan-07 0:33
Seishin#25-Jan-07 0:33 
GeneralRe: messageBox buttons related issue Pin
Stefan Troschuetz24-Jan-07 22:28
Stefan Troschuetz24-Jan-07 22:28 
GeneralRe: messageBox buttons related issue Pin
quiteSmart24-Jan-07 22:31
quiteSmart24-Jan-07 22:31 
GeneralRe: messageBox buttons related issue Pin
Stefan Troschuetz24-Jan-07 22:40
Stefan Troschuetz24-Jan-07 22:40 
GeneralRe: messageBox buttons related issue Pin
quiteSmart24-Jan-07 22:45
quiteSmart24-Jan-07 22:45 
GeneralRe: messageBox buttons related issue Pin
Dan Neely25-Jan-07 2:19
Dan Neely25-Jan-07 2:19 
GeneralRe: messageBox buttons related issue Pin
Robert Rohde24-Jan-07 22:41
Robert Rohde24-Jan-07 22:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.