Click here to Skip to main content
15,889,335 members
Home / Discussions / Database
   

Database

 
Questiondataset size limits... Pin
l a u r e n20-Sep-05 18:54
l a u r e n20-Sep-05 18:54 
AnswerRe: dataset size limits... Pin
Andy Brummer20-Sep-05 19:46
sitebuilderAndy Brummer20-Sep-05 19:46 
Questionxml schemas... Pin
l a u r e n20-Sep-05 17:11
l a u r e n20-Sep-05 17:11 
AnswerRe: xml schemas... Pin
Andy Brummer20-Sep-05 19:54
sitebuilderAndy Brummer20-Sep-05 19:54 
QuestionBest practices for user defined fields Pin
econner20-Sep-05 16:42
econner20-Sep-05 16:42 
AnswerRe: Best practices for user defined fields Pin
Edbert P20-Sep-05 18:27
Edbert P20-Sep-05 18:27 
AnswerRe: Best practices for user defined fields Pin
Andy Brummer20-Sep-05 20:01
sitebuilderAndy Brummer20-Sep-05 20:01 
QuestionDatabound ComboBox Selection Problems Pin
Glenn E. Lanier II20-Sep-05 15:33
Glenn E. Lanier II20-Sep-05 15:33 
I am displaying a ComboBox that hopefully contains the contents of a database table (a lookup of sorts). When the form loads, the ComboBox contains the correct values, all sorted. Smile | :)

However, when I try to select a value programitically, I can't (well, I can't select the correct one). Frown | :(

I create a dataset:
DataSet dsTitles = new DataSet("Titles");<br />
SqlCommand tableCommand = new SqlCommand();<br />
tableCommand.CommandText = "select TitleID, TitleDisplayText FROM tblTitles WHERE TitleHidden <> 1";<br />
<br />
SqlDataAdapter adapter = new SqlDataAdapter();<br />
adapter.SelectCommand = tableCommand;<br />
adapter.Fill(dsTitles, "Titles"); 


I then bind the dataset to the ComboBox:
comboBoxTitle.BeginUpdate();<br />
comboBoxTitle.DataSource = db.DataSetTitles.Tables["Titles"];<br />
comboBoxTitle.DisplayMember = "TitleDisplayText";<br />
comboBoxTitle.ValueMember = "TitleID";<br />
comboBoxTitle.EndUpdate();


So far, all is well. However, I can't seem to select the correct item. I've tried:
comboBoxTitle.SelectedValue = 2;<br />
Console.WriteLine("Current Title Index: {0} Text: {1} Combo Index: {2} Value: {3} Text: {4}", 2, db.LookupValueTitle(2), comboBoxTitle.SelectedIndex, comboBoxTitle.SelectedValue);<br />


TitleID of 2 matches TitleDisplayText of Mr, but nothing is visibily selected.

Current Title Index: 2 Text: Mr Combo Index: 0 Value: 2 Text: 
is what gets logged.

Any help would be appreciated.

--G Confused | :confused:
AnswerRe: Databound ComboBox Selection Problems Pin
sreejith ss nair22-Sep-05 1:06
sreejith ss nair22-Sep-05 1:06 
AnswerRe: Databound ComboBox Selection Problems Pin
Glenn E. Lanier II2-Mar-06 8:36
Glenn E. Lanier II2-Mar-06 8:36 
AnswerRe: Databound ComboBox Selection Problems Pin
miah alom22-Sep-05 3:23
miah alom22-Sep-05 3:23 
QuestionSelecting distinct values Pin
Filipe Peixinho20-Sep-05 12:28
Filipe Peixinho20-Sep-05 12:28 
AnswerRe: Selecting distinct values Pin
enjoycrack20-Sep-05 17:17
enjoycrack20-Sep-05 17:17 
GeneralRe: Selecting distinct values Pin
Filipe Peixinho21-Sep-05 0:55
Filipe Peixinho21-Sep-05 0:55 
GeneralRe: Selecting distinct values Pin
enjoycrack21-Sep-05 0:57
enjoycrack21-Sep-05 0:57 
GeneralRe: Selecting distinct values Pin
Filipe Peixinho21-Sep-05 1:12
Filipe Peixinho21-Sep-05 1:12 
GeneralRe: Selecting distinct values Pin
enjoycrack21-Sep-05 1:17
enjoycrack21-Sep-05 1:17 
GeneralRe: Selecting distinct values Pin
Filipe Peixinho21-Sep-05 1:38
Filipe Peixinho21-Sep-05 1:38 
GeneralRe: Selecting distinct values Pin
enjoycrack21-Sep-05 2:01
enjoycrack21-Sep-05 2:01 
GeneralRe: Selecting distinct values Pin
Filipe Peixinho21-Sep-05 3:26
Filipe Peixinho21-Sep-05 3:26 
GeneralRe: Selecting distinct values Pin
miah alom22-Sep-05 5:06
miah alom22-Sep-05 5:06 
QuestionWhen LIKE operator doesn't use indexes. Pin
Tupax20-Sep-05 6:18
Tupax20-Sep-05 6:18 
AnswerRe: When LIKE operator doesn't use indexes. Pin
Andy Brummer20-Sep-05 8:02
sitebuilderAndy Brummer20-Sep-05 8:02 
GeneralRe: When LIKE operator doesn't use indexes. Pin
Tupax20-Sep-05 21:43
Tupax20-Sep-05 21:43 
QuestionRe: When LIKE operator doesn't use indexes. Pin
Tupax20-Sep-05 21:57
Tupax20-Sep-05 21:57 

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.