|
-
Jul 9th, 2009, 04:00 PM
#1
Thread Starter
New Member
Fill a Combo Box/DropDownList
I am trying to fill a combo box from SQL Server 2008. Getting the Combo Box to populate isn't the problem. What I need to do is have the text field read the field value that goes with a specific id that I search by, while keeping all other fields available to chose from to change the value for that specific id and save back to the database. I know this isn't clear here is the best example I can think of:
COMBOBOX --FieldValue------->
--DropDownField1--> Ten
--DropDownField2--> Twenty
--DropDownField3--> Thirty
--DropDownField4--> Forty
Search by id: 301
COMBOBOX --FieldValue----> Thirty
--DropDownField1--> Ten
--DropDownField2--> Twenty
--DropDownField3--> Thirty
--DropDownField4--> Forty
Here is the code I am using to populate the cbo:
Private Sub PopulateAccrualCombo()
Dim ds As New DataSet
Dim da As New SqlClient.SqlDataAdapter
ds.Tables.Add("ComboTable")
da.SelectCommand = New SqlClient.SqlCommand
("SELECT MethodName, MethodID " & vbCrLf & _
"FROM" & vbCrLf & _
"acAccountingMethod ", Me.cn)
da.Fill(ds.Tables("ComboTable"))
wcboAccrualMethodsFuture.DataSource = ds.Tables("ComboTable")
wcboAccrualMethodsFuture.DataValueField = "MethodID"
wcboAccrualMethodsFuture.DataTextField = "MethodName"
'Configuration for Future Accrual Rate
Me.wcboAccrualMethodsFuture.Columns.Band.GridLines = Infragistics.WebUI.UltraWebGrid.UltraGridLines.None
Me.wcboAccrualMethodsFuture.Columns.Band.ColHeadersVisible = Infragistics.WebUI.UltraWebGrid.ShowMarginInfo.No
Me.wcboAccrualMethodsFuture.Columns.Band.RowSelectors = Infragistics.WebUI.UltraWebGrid.RowSelectors.No
Me.wcboAccrualMethodsFuture.Columns.FromKey("MethodName").Hidden = True
Any ideas I seriously might have to infest in some Rogaine if I have to spend another ten minutes on this. I do know that I am missing an id to compare to but when I add the id into the sql statement the combo box only fills with the one value that it equals to without the option to chose from the several others to change.
Thanks in advance,
Dylan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|