C# 如何从下拉列表选择更改文本框中的数据显示?
大家好,作为我发布的主题。我真的需要知道,如何从DDL中得到可以自动改变文本框显示的结果。我们的每件商品都有不止一个尺码,有时当您点击不同尺码时,价格会有所不同。如何实现此功能 如果有任何帮助,我将不胜感激 以下是我的示例代码: 详细信息。aspx:C# 如何从下拉列表选择更改文本框中的数据显示?,c#,asp.net,data-binding,.net-3.5,C#,Asp.net,Data Binding,.net 3.5,大家好,作为我发布的主题。我真的需要知道,如何从DDL中得到可以自动改变文本框显示的结果。我们的每件商品都有不止一个尺码,有时当您点击不同尺码时,价格会有所不同。如何实现此功能 如果有任何帮助,我将不胜感激 以下是我的示例代码: 详细信息。aspx: <asp:TemplateField SortExpression="Size" ItemStyle-Wrap="True" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="
<asp:TemplateField SortExpression="Size" ItemStyle-Wrap="True" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Bottom" HeaderStyle-Wrap="False" HeaderText="Options">
<ItemTemplate>
Size:<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SizeSource" AutoPostBack="true" DataTextField="Size" DataValueField="Size" Height="22px" Width="60px">
</asp:DropDownList>
Qty:<asp:TextBox ID="TextBox2" runat="server" Height="16px" Width="30px" Text="<%# 1 %>"></asp:TextBox>
<br />
Price(USD):
<asp:TextBox runat="server" DataSourceID="SizeSource" SortExpression="Price" DataFormatString="{0}" ID="PriceList" Width="50px" Height="16px" ValidationGroup="Price" AutoPostBack="True" />
<asp:SqlDataSource ID="SizeSource" runat="server" ConnectionString="<%$ ConnectionStrings:LIFEbabySAP %>" SelectCommand="SELECT left(T0.ItemCode,8) as Image, left(T0.ItemCode,8) as Code, T0.U_ItemName as Name, T0.U_Size as Size, T0.U_Colour as Color,case T1.Onhand when 0 then 'Out of Stock' else 'In Stock' end as Availability, T0.UserText as Description, CAST(T2.Price as Int)as Price FROM OITM T0 inner join oitw T1 on T0.ItemCode = T1.Itemcode inner join itm1 T2 on T0.ItemCode = T2.ItemCode WHERE (left(T0.ItemCode,8) = @Image) and T0.U_USE = 'Y' and T1.Onhand != 0 and T1.whscode ='BAW' and T2.PriceList = 10">
<SelectParameters>
<asp:QueryStringParameter Name="Image" QueryStringField="product" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
<HeaderStyle Wrap="False"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Bottom" Wrap="True"></ItemStyle>
</asp:TemplateField>
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
string Size = Request.QueryString["Price"];
if (Size != null)
{
ddlCategory.SelectedValue = Size;
}
}
ItemsGet();
}
protected void CatalogList_SelectedIndexChanged(object sender, EventArgs e)
{
string Image = CatalogList.SelectedValue.ToString().Trim();
string catid = ddlCategory.SelectedValue;
Response.Redirect("Details.aspx?product="
+ Image
+ "&Price="
+ catid);
}
您能再指定一点吗?您想获取下拉值并将其放入文本框中吗?这是否将在服务器控件中(即gridview、datalist等…)