Hi guys as the subject i posted. I really need to know, how to get result from DDL that can automatically changes the display in the TextBox. Our each item has got more than one size and sometimes the price will be different when you click on a different size. How can I implement this function?
Any help, I would appreciated.
Here is my sample code:
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);
}