Here's a simple page (Cut and Paste and see what I mean) where I want my textbox (ID=TextBox1)
to have the same data as the drop down list (ID=DropDownList3) upon Page Load or Page Render or Page Init.
My problem is I CANNOT get the textbox with the data that I want
because an ASP textbox does NOT have a dataSource.
How do I set the Textbox with the value that I want?
*******************************
***** Begin of Data ***********
*******************************
drop table prod_t
create table prod_t (category varchar(10), item varchar(20), loc varchar(20))
insert into prod_t (category, item, loc) values ('CAT 1', 'CAT 1.Item 1', 'CAT 1.LOC 1')
insert into prod_t (category, item, loc) values ('CAT 1', 'CAT 1.Item 2', 'CAT 1.LOC 2')
insert into prod_t (category, item, loc) values ('CAT 1', 'CAT 1.Item 3', 'CAT 1.LOC 3')
insert into prod_t (category, item, loc) values ('CAT 2', 'CAT 2.Item 1', 'CAT 2.LOC 1')
insert into prod_t (category, item, loc) values ('CAT 2', 'CAT 2.Item 2', 'CAT 2.LOC 2')
insert into prod_t (category, item, loc) values ('CAT 2', 'CAT 2.Item 3', 'CAT 2.LOC 3')
*******************************
***** End of Data ***********
*******************************
***************************************
***** Begin of ASP.NET Code ***********
***************************************
<%@ Page Language="
VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<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" DataSourceID="SqlDataSource1"
DataTextField="category" DataValueField="category" Style="z-index: 100; left: 178px;
position: absolute; top: 104px" AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:localsqlserver %>"
SelectCommand="select distinct category from prod_t"></asp:SqlDataSource>
<asp:Label ID="Label1" runat="server" Style="z-index: 101; left: 104px; position: absolute;
top: 110px" Text="Category" Width="67px"></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
DataTextField="item" DataValueField="item" Style="z-index: 102; left: 179px;
position: absolute; top: 131px">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:localsqlserver%>"
SelectCommand="select item from prod_t where category=@category">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="category" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:Label ID="label2" runat="server" Style="z-index: 103; left: 143px; position: absolute;
top: 134px" Text="Item" Width="28px"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 104; left: 181px; position: absolute;
top: 157px"></asp:TextBox>
<asp:Label ID="Label3" runat="server" Style="z-index: 105; left: 43px; position: absolute;
top: 158px" Text="Location (Textbox)" Width="130px"></asp:Label>
<asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource3"
DataTextField="loc" DataValueField="loc" Style="z-index: 106; left: 184px; position: absolute;
top: 186px">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:localsqlserver%>"
SelectCommand="select loc from prod_t where category=@category and item=@item">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="category" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList2" Name="item" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:Label ID="Label4" runat="server" Style="z-index: 108; left: 10px; position: absolute;
top: 186px" Text="Location (DropDownList)" Width="171px"></asp:Label>
</div>
</form>
</body>
</html>
***************************************
***** END of ASP.NET Code ***********
***************************************