issue when populating data in textbox on dropdownlist box selection

D

Dhananjay

Hi all,

i have a webpage on which
first thing i am adding record using textboxadd and buttonadd.
------
this works fine
second thing i have dropdownlist box on which i will select an item,
based on this selection , i have another textboxforedit(this textbox
will be populated with dropdownlist box selected item).
in this textboxforedit i will modify the data and i have a update
button,if i click update button, it should be updated in the table.


please help me to solve this problem.it's urgent
please send me some code to solve this issue.


Thanks in advance
Dhananjay
 
M

Mike Placentra II

...i have dropdownlist box on which i will select an item,
based on this selection , i have another textboxforedit(this textbox
will be populated with dropdownlist box selected item).
in this textboxforedit i will modify the data and i have a update
button,if i click update button, it should be updated in the table.

This is nothing complicated, I'm assuming you are trying to use a
DropDownList to prefill a TextBox so people don't have to type common
things.

What you need to do is create a DropDownList with the AutoPostBack
attribute set to True, and then handle it's SelectedIndexChanged event
to set the Text property to the value of the SelectedValue property of
the DropDownList:

<asp:DropDownList ... AutoPostBack="True">
<asp:ListItem Selected="True">Pre-typed things</asp:ListItem>
...
</asp:DropDownList>
<asp:TextBox ... />

Here's an outline of how you would handle the event:

Sub DropDownList1_SelectedIndexChanged(sender as object, ...)
Handles ...
TextBox1.Text = CType(sender, DropDownList).SelectedValue
End Sub

I'm not sure what you mean by updating the database, it's unstated
whether this is a new record or editing a record, if there is already
existing code that this will work alongside, etc. You will have to
explain your problem further.

-Michael Placentra II
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top