Datalist in Updatepanel will not clear

  • Thread starter Thread starter Guest 20221009
  • Start date Start date
G

Guest 20221009

Guest
So I am working on page with Telerik's web UI and I have added an updatepanel to do a partial update on the page. My control has Datalist that get it's data from a custom List<T> object based on the value of some Dropdownlist. This works fine when there is no updatepanel in use, but the moment I add the updatepanel, the datalist adds the new object without cleariing out the default item.

List<Conditions> conditions = new List<Conditions>();

if (IsPostBack)
{

DataList1.DataSource = null;

DataList1.DataBind();
}


conditions = Conditions.GetForecast(CityList.SelectedValue);
var current = Conditions.GetCurrentConditions(CityList.SelectedValue);




if (CurrentCondition != null)
{
CurrentImage.ImageUrl = "~/images/weathericons/" + current.Condition.ToLower() + ".png";
}

CurrentCity.Text = current.City;
CurrentCondition.Text = current.Condition;
CurrentTemp.Text = current.High;
CurrentHumidty.Text = current.Humidity;

I have tried forcing the Datalist to clear on postback, just before creating the new object and I have had no luck. help :(
 
Well I cheated and just hid the Datalist on Postback and it works. The funny thing is that the mark up for the default data does not even show up in the view source. :confused:
 
Did you enable auto postback on the datalist? or set the updatepanel to manually triggered updates and call the .Update() function?
 
Did you enable auto postback on the datalist? or set the updatepanel to manually triggered updates and call the .Update() function?

Nope, I had not forced the Updatepanel to do either of the things you mentioned. My Dlist does not seem to have an Autopostback property. Anyways I have got it working after some time but I was dumb enough not to check the step taht actually fixed it. :wtf:
 
Top
Sign up to the MyBroadband newsletter
X