Copy link to clipboard
Copied
I'm converting one of my Access forms into ASP and I'm having trouble mimicking Access's combobox features in ASP.
In my original form, I have a combobox bound to a lookup table that writes the selection into a master table field.
The combobox works like this in Access:
Row Source: SELECT sourceCodes.name FROM sourceCodes;
Control source: source (a field in my master table)
In Dreamweaver, I was able to populate a DropDownList with the same query as a Dataset ('sourceDropDown'):
<asp:DropDownList ID="DropDownList1" DataSource="<%# sourceDropDown.DefaultView %>" DataTextField="name" DataValueField="code" runat="server"></asp:DropDownList>
But I'm at a lack of how to write this data when a selection is made. The ASP page I'm making is set up to be an update form by default. How do I tie a combobox change into the update action or do I do something like an AfterUpdate for the DropDownList to write the selection back to the table immediately?
Goes without saying that I'm new to ASP. Any help or even pointers in the right direction would be really appreciated!
Thanks in advance!
[Subject line edited by moderator to indicate server technology used]
Copy link to clipboard
Copied
>I'm converting one of my Access forms into ASP and
>I'm having trouble mimicking Access's combobox features in ASP.
Looks like ASP.NET, right? Is that what you intended or did you mean to create a classic ASP page? Other than the 3 letters, ASP and ASP.NET are completely different animals.
>But I'm at a lack of how to write this data when a selection is made.
You shouldn't need to do anything special. The value that's populated in the form field should be passed to the update script when the form is submitted. What type of problem are you having?
Copy link to clipboard
Copied
Thanks for your reply!
The problem I'm still seeing is that my DropDrown code doesn't seem to have anything in it to direct the selected DropDown item to a table's field. It does have a DataSource, which gives the DropDown its items, but I need to tell it where to put data when a selection is made, like "Control Source" in Access.
' This populates the DropDownList from a lookup table, but doesn't have any info on where to store selected data.
<asp:DropDownList ID="DropDownList1" DataSource="<%# sourceDropDown.DefaultView %>" DataTextField="name" DataValueField="name" runat="server"></asp:DropDownList>
' I'm using this code so the DropDown reads the actual field I'm trying to update ('source' from my dataset inventoryQry). This is part of the functionality that I want, but I also need to update the field if a selection is made from the DropDown
<% DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(inventoryQry.FieldValue("source", Nothing) )) %>
I'll keep digging around. If you have any other pointers, thank you in advance!