Fetching values from the DropDownlist on PostBack inside Repeater Control in ASP.Net -
i have repeater control
on 1 of asp.net page, have labels , 1 dropdownlist
in repeater control. default contents filled in label , dropdownlist item_bound
event. want achieve below:
- when user selects item dropdownlist, labels should updated accordingly.
my problem here is, default content coming item_bound
, over-rides content dropdownlist, if place !ispostback
condition inside item_bound event, on selecting dropdownlist nothing happens.
i have used onselectedindexchange event, , providing response.write inside event, dropdownlist values overrides itself, don't on response.
can me logic how shall tackle this.
updated question:
ok able fetch results in repeater label selecteditems dropdown, problem have binded multiple results inside repeater, i.e. each dropdowns per row, when select items row, still assumes value of first row. here code reference:
protected void drpquantity_selectedindexchanged(object sender, eventargs e) //dropdown inside repeater control. { foreach (repeateritem item in rptlatestproducts.items) { if (item.itemtype == listitemtype.item) { hiddenfield hd = item.findcontrol("hdproductid") hiddenfield; dropdownlist drp = item.findcontrol("drpquantity") dropdownlist; label mrp = item.findcontrol("lblmrp") label; label ourprice = item.findcontrol("lblourprice") label; label discount = item.findcontrol("lbldiscount") label; scriptmanager.registerstartupscript(updpricebyunits, this.gettype(), "alert", "alert('" + hd.value + "')", true); //always returns product id of first row. objpackage.productid = convert.toint32(hd.value); objpackage.townid = objpackage.defaulttown; int discountpercent = convert.toint32(objpackage.getproductpackages().select("unit=" + drp.selectedvalue + " , productid=" + hd.value)[0]["discount"].tostring()); mrp.text = "<span class='rupee' style='font-size:14px;'>rs</span>" + objpackage.getproductpackages().select("unit=" + drp.selectedvalue + " , productid=" + hd.value)[0]["mrp"].tostring(); ourprice.text = "<span class='rupee' style='font-size:14px;'>rs</span>" + objpackage.getproductpackages().select("unit=" + drp.selectedvalue + " , productid=" + hd.value)[0]["price"].tostring(); mrp.visible = (mrp.text != ourprice.text); if (discountpercent > 0) { discount.visible = true; discount.text = objpackage.getproductpackages().select("unit=" + drp.selectedvalue + " , productid=" + hd.value)[0]["discount"].tostring() + "% off"; } else { discount.visible = false; } } } }
can please me this
sounds putting !page.ispostback
around wrong bit of code.
you need put around databind
code. so;
if (!page.ispostback){ this.myrepeater.datasource = [yourdatasource]; this.myrepeater.databind(); }
this way dropdownlist
controls not rebound.
Comments
Post a Comment