Solved

displaying values in a combobox

Posted on 2009-05-13
3
297 Views
Last Modified: 2013-11-26
I am trying to display the stored value of a previously selected item using a combobox. To put it as simply as possible I have a status table which holds the following values
1, proposed
2, accepted
3, denied

When the user is first entering a record they will select one of the statuses displayed in the combobox, then the system will save the numeric value of that item in a table in my database. Then later in time someone will review the proposed item and change the selected value to whichever is appropriate.

If someone selects a value I can store it no problem. the problem rises when someone goes in and reviews a record. I can either get the previously selected value and not display it. (ie I can store the 1 for proposed but the combobox displays an empty string) or I can display the text value of the previously selected item and not have the actual value of the selected item. (ie, display "proposed" in the combobox but the selected value = 0)

Can someone explain to me how I can have my displayed text and my selected value both be correct using vb.net? I have the code I've been trying to get to work below.
cmbStatus.SelectedValue = iStatus
                cmbStatus.SelectedText = dsICMMS.statusTbl.Rows(StatusTblBindingSource.Find("statusID", iStatus)).Item("status")

Open in new window

0
Comment
Question by:ITatIG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24380690
Try this



For ctr as integer = 0 to Combobox1.items.count -1
 
If Combobox1.items.item(ctr) = dsICMMS.statusTbl.Rows(StatusTblBindingSource.Find("statusID", iStatus)).Item("status")
 
Combobox1.SelectedItem = ctr
exit for
end if
 
Next

Open in new window

0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24380698
oopps typo error...

Try the below code instead...
For ctr as integer = 0 to Combobox1.items.count -1
 
If Combobox1.items.item(ctr) = dsICMMS.statusTbl.Rows(StatusTblBindingSource.Find("statusID", iStatus)).Item("status") then
 
Combobox1.SelectedItem = ctr
exit for
end if
 
Next

Open in new window

0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 125 total points
ID: 24380708
or this one

For ctr as integer = 0 to Combobox1.items.count -1
 
If Combobox1.items.item(ctr) = dsICMMS.statusTbl.Rows(StatusTblBindingSource.Find("statusID", iStatus)).Item("status") then
 
Combobox1.SelectedIndex = ctr
exit for
end if
 
Next

Open in new window

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
orderby list (from Json) 1 44
Error import assembly 19 30
Shared Service Environment 2 54
EF5 How do I stop pre-compiled views? 8 54
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question