Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Setting Value of combobox different than text

$
0
0

Hi,

I populate a dropdown from a recordset of names.  I need for the NAME to display but the value to be another column called PERNO.  Here's how I populate it.

ds = new SqlDataAdapter("select distinct name from 
                empmast order by name", con);

ds.Fill(dt);

for (int i = 0; i < dt.Rows.Count; i++)
   {
      cbOfficer.Items.Add(dt.Rows[i]["name"]);
   }

I'm guessing I need to query PERNO as well, but how I set it to be the actual value of what is selected?

Is it the ValueMember attribute?


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>