jseaman12
asked on
Dropdownlist populates Text Box in ASP.net
I have a query that populates a drop down list. It has two fields NAME | TERRITORY
Textbox is blank. When end user selects the drop down list then the TERRITORY is populated in the textbox.
How can I do this in ASP.NET
Here is my code
Textbox is blank. When end user selects the drop down list then the TERRITORY is populated in the textbox.
How can I do this in ASP.NET
Here is my code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="name"
Height="26px" Width="127px">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ordersConnectionString %>"
SelectCommand="SELECT [name], [territory] FROM [names]"></asp:SqlDataSource>
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One more thing is in this HTML code u should set the 'DataValueField=TERRITORY' .