I'm using the script manager + update panel on my drop down list so when the user selects something out of it, the page wouldn't refresh(this is my goal).
Here is the HTML code:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:ListView ID="listProducts" runat="server" DataKeyNames="ProductID" OnItemDataBound="listProducts_ItemDataBound" OnItemCommand="listProducts_ItemCommand">
<ItemTemplate>
<div class="productoverlay">
<div class="col-lg-4 proizvod">
<div class="product">
<div class="glow"></div>
<img src='<%# "../productimg/" + Eval("FileName")%>' alt='<%# Eval("ProductName") %>'/>
</div>
</div>
<div class="col-lg-1 price">
<asp:Label ID="lblPrice" runat="server" Text=""></asp:Label>
</div>
<div class="col-lg-7 pushtop">
<h1><%# Eval("ProductName") %></h1>
<p>Description: </p>
<p><%# Eval("ProductDescription") %></p>
<p>Quantity: </p><asp:TextBox ID="txtPackageQuantity" TextMode="Number" runat="server"></asp:TextBox>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger controlid="DropDownList1" eventname="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" runat="server"></asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" Text="Add to cart" CommandName="AddToCart" CommandArgument='<%# Eval("ProductID")%>'/>
</div>
</div>
</ItemTemplate>
</asp:ListView>
And this is the code for the OnSelectedIndexChanged event:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
var ddl = sender as DropDownList;
var val = int.Parse(ddl.SelectedValue);
rlsp_PrCategories_ByID_Result pr = ServiceClass.ProductCatByID(val);
Label lblPrice = ddl.Parent.FindControl("lblPrice") as Label;
if(pr!=null)
lblPrice.Text = "$ " + pr.Price;
}
The problem is that now when I added script manager + update panel (async postback trigger), now when I select something out of the dropdown list, the page doesn't refreshes, but the label also doesn't shows anything (it should change price when I select something out of the drop down menu).
What am I doing wrong here? Can someone help me out?
P.S. I just checked if the event fires up now when user selects something, and yes it fires up, but I don't seem to be able to see the content of that label (its not printed out on the page)...?
Tell the updatepanel to refresh after doing edits, because updatemode is set to conditional in ur markup.
UpdatePanel1.Update()