onitemdatabound doesn't work after postback

xplosion

New Member
Here is my page codes. I just want to display my records. There is also search panel at the page. In the search panel, there are a couple of dropdownlist control and they have OnSelectedIndexChanged methods. When I change the selected item on the first dropdownlist, my onItemDatabound events which belongs the repeater does not work any more.What happens instead: in the \[code\]ItemDataBound\[/code\] event, I add the each record's picture at the panels dynamically. So, when I change the selected item of the dropdownlist the pictures disappear.\[code\] protected void Page_Load(object sender, EventArgs e){ if (!IsPostBack) { DataBindToPage(); }}protected void DataBindToPage(){ rptLast.DataSource = EntitiyProvider.GetAdvertListLatest(); rptLast.DataBind(); rptSchool.DataSource = EntitiyProvider.GetAdvertListLatest("Ders Kitab?"); rptSchool.DataBind(); rptBook.DataSource = EntitiyProvider.GetAdvertListLatest("Edebi Eser"); rptBook.DataBind();}protected void rptLast_ItemDataBound(object sender, RepeaterItemEventArgs e){ if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { Advert adv = (Advert)e.Item.DataItem; Panel pnlLastAdvertPic = (Panel)e.Item.FindControl("pnlLastAdvertPic"); List<AdvertPicture> advPic = EntitiyProvider.GetAdvertKapakPicByAdvertId(adv.id); if (advPic.Count != 0) { string picPath = string.Empty; foreach (AdvertPicture item in advPic) { if (item.primePicture == true) { picPath = item.picturePath; } } if (picPath == string.Empty) { pnlLastAdvertPic.Controls.Add(new Image { ImageUrl = "~/uploads/" + advPic[0].picturePath, Width = 140, CssClass="rpTable" }); } else { pnlLastAdvertPic.Controls.Add(new Image { ImageUrl = "~/uploads/" + picPath, Width = 140, CssClass = "rpTable" }); } } else { pnlLastAdvertPic.Controls.Add(new Image { ImageUrl = "~/images/Noimage.gif", Width = 120, CssClass = "rpTable" }); } } }\[/code\]
 
Back
Top