TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chris
NA
16
4.3k
Populate textboxes from a dropdownlist
Jun 11 2014 10:22 AM
Hi, I am quite new to ASP.Net and am having a problem with a dropdownlist. The user will choose a site number from the dropdownlist. This should then automatically populate the textboxes called site_name, site_address, site_county and site_postcode with data from the following SQL command:
SELECT site_num, site_name, site_address, site_county, site_postcode FROM SCSite WHERE Site_Num = <value from dropdownlist>
I believe that I should be using OnSelectedIndexChanged, but am stuck with the C# code behind to achieve the population of the textboxes. Below is the code for the relevant section of the main page.
Any help would be most grateful!
<td>
<asp:DropDownList ID="Top_Site_NumDropDown" AppendDataBoundItems="true" runat="server" DataSourceID="SqlDataSourceSite" DataTextField="Site_Num" DataValueField="Site_Num" AutoPostBack="true" OnSelectedIndexChanged="Top_Site_NumDropDown_SelectedIndexChanged" SelectedValue='<%# Bind("Top_Site_Num") %>' >
<asp:ListItem Value="">Please Select</asp:ListItem>
</asp:DropDownList>
</tr>
<tr>
<td>Site Name</td>
<td><asp:TextBox ID="Top_Site_NameTextBox" runat="server" Text='<%# Bind("Top_Site_Name") %>' Width="95%" />
</td>
</tr>
<tr>
<td>Address</td>
<td><asp:TextBox ID="Top_Site_AddressTextBox" runat="server" Height="4em" Text='<%# Bind("Top_Site_Address") %>' TextMode="MultiLine" Width="95%" /></td>
</tr>
<tr>
<td>County</td>
<td><asp:TextBox ID="Top_Site_CountyTextBox" runat="server" Text='<%# Bind("Top_Site_County") %>' /></td>
</tr>
<tr>
<td>Postcode</td>
<td><asp:TextBox ID="Top_Site_PostcodeTextBox" runat="server" Text='<%# Bind("Top_Site_Postcode") %>' /></td>
</tr>
Reply
Answers (
5
)
how to decode qr code in asp.net using web cam
Create DropDownListFor in MVC and bind data from Database