大家好,我发布的主题。我真的需要知道,如何从DDL获取可以自动更改TextBox中显示的结果。我们的每件商品都有不止一种尺寸,当您点击不同尺码时,价格会有所不同。我该如何实现这个功能?
任何帮助,我都会感激。
以下是我的示例代码:
Details.aspx:
<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>
Catalog.aspx.cs CodeBehind(C#):
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);
}
答案 0 :(得分:0)
你能指定一点,你想要下拉值并把它放在文本框中吗?这将是一个服务器控件(即gridview,datalist等....)