I have a very old tick: whenever I’m setting the datasource for a Repeater I always set it first to null.
this.rptMyRepeater.DataSource = null; //is this line necessary?
this.rptMyRepeater.DataSource = pNewSource;
this.rptMyRepeater.DataBind();
I don’t even remember why I started doing that but I’m sure I had some ugly issues associated with data-bound objects not binding properly if I didn’t assign null first.
Years have passed and new framework versions came, maybe it was some old bug or maybe I was plain wrong.
Is it necessary to assign null to data-bound objects DataSource property before setting it?
After reading the comments, the Ray Cheng’s comments on Jeppe’s answer and waiting for someone with evidence of this being neccesary, I conclude the answer is no, it is not neccesary to assign null to the DataSource before reassigning it.