Is this possible

  • Thread starter Thread starter Phenom
  • Start date Start date
P

Phenom

I have a form that a user can enter an ID number, pull the data back
and edit and update the data. So far, any simple controls, such as text

boxes work.


I have 4 controls that are dropdownlists populated by a database. I
would like to keep these dropdownlists populated by the database, but
if the dataset returns a value, I would like that value to become the
selectedvalue for the drop downs.


I know how to do this in ASP, but so far when I search the internet for

info on ado.net/asp.net I don't find any way to reference a specific
column in a dataset.


Is this possible? Can you point me somewhere that shows an example of
this or post a brief example in response?


Thanks in advance.
 
Hi,

You're able to do it for a textbox, but not a combobox? The techniques are
relatively similar. To reference a column of any row in a dataset, for
example:

ds.Tables(0).Rows(intRowNumber).Item(4).ToString()

You can assign this to the selectedvalue property of your combobox.

I am assuming you've already filled out the comboboxes with the
'predetermined' values?

-Altaf
 
Well, the text boxes are bound to a dataset. When a user enters a
number and clicks the 'search' button, the query is ran. If results are
found, I have txtBox.databind(). I'll post what little code for this I
have. The problem with the combo box is that it is already bound to a
different query. For instance, I pull in employee names in one table to
select. I'd like, when the query is ran, for the program to display the
item in the list that matches the item in the dataset.

In old asp, I would simply have an if then - if rst1("item") =
rst2("item") then response.write "selected" . I'm not finding a good
instance of anything similar.

Here is my code:
Notes**** - the view I am pulling is a view that selects only the items
I need from different tables in the database, which is why I do a
select * instead of naming each individual field.
Also - the last line is commented out. It was my attempt through
'guessing with intellisense' what might be the way to reference that
particular field in a dataset.

sqlChange.CommandText = "Select * from vw01_ViewChangeControl where
event_id = " & txtEditForm.Text
daUpdate.Fill(DsUpdate1)

txtRequestor.DataBind()
txtImpacted.DataBind()
txtProjRequestNo.DataBind()
txtHelpDeskNo.DataBind()
txtSubject.DataBind()
txtReason.DataBind()
txtNotes.DataBind()
txtSchedImplement.DataBind()
txtActualImplement.DataBind()
rdBtnInterrupt.DataBind()
txtInterruptMin.DataBind()
btnImplementFile.DataBind()
btnBackoutFile.DataBind()
Label7.DataBind() 'used only to make sure correct event_id is
returned in the query. This will not be used when program is finished.

'ddlAssigned.SelectedItem =
DsUpdate1.vw01_ViewChangeControl.Columns.Item("emp_name")

I'll try your example. If what I've written somehow changes your
answer, please let me know. I appreciate your feedback.
 
Back
Top