Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdownlist Value Generated from Textbox Input

Status
Not open for further replies.

net123

Programmer
Oct 18, 2002
167
US
I have a web form where a user enters some fields via textboxes and dropdownlists. Let's assume one of the textboxes is asking for NAME and there is a dropdownlist named IssuedTo where there are 2 options only: same person from the NAME textbox or some other generic place like MyCompany.

If I have the following for my ddl:

<asp:dropdownlist id=&quot;ddlToWho&quot; runat=&quot;server&quot;>
<asp:ListItem Value=&quot;Same&quot; Selected=&quot;True&quot;>Name</asp:ListItem>
<asp:ListItem Value=&quot;Company&quot;>Company</asp:ListItem>
</asp:dropdownlist>
[/red]

How can I replace the first value in my DDL with a value from the NAME textbox? I am assuming I will have to do a postback and get that value, but don't know the syntax.

Thanks in advance.
 
Private Sub txtJobName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtJobName.TextChanged

clear list items
add list items
End Sub

set autopostback to true for textbox
 
After populating the Drop Down List, add an item like this:

ddlToWho.Items.Insert(0, txtName.Text)'inserts at first position

If you wish to have the option available for the page on future visits, you will, of course, need to store the value in your database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top