0

I have a repeter in page. I set datasource for it in page load.

 LikeRepeater.DataSource = clsForumQuestionLikeViewFactory.GetAllByFieldDT(clsForumQuestionLikeView.clsForumQuestionLikeViewFields.QuestionID, id);
 LikeRepeater.DataBind();

I have a linkbutton. when click it, I add a record to database and set datatsource for repeater.

protected void ParentLikeButton_Click(object sender, EventArgs e)
{
 LikeRepeater.DataSource = clsForumQuestionLikeViewFactory.GetAllByFieldDT(clsForumQuestionLikeView.clsForumQuestionLikeViewFields.QuestionID, IDLabel.Value);
 LikeRepeater.DataBind();
}

It have two item but show one, Repeater don't refresh.

How to refresh it?

शेखर
  • 17,412
  • 13
  • 61
  • 117
Niloo
  • 1,205
  • 5
  • 29
  • 53
  • which version of .net are you using? have you tried searching the documentation for something like : `LikeRepeater.refresh()` ? is the LikeRepeater a class? because it gets highlighted as class here. i guess its an object though ... – Vogel612 Jan 07 '13 at 06:19
  • also this is possibly a duplicate of http://stackoverflow.com/questions/463317/how-to-dynamically-refresh-a-net-databound-repeater-control – Vogel612 Jan 07 '13 at 06:20
  • are you adding to the database first and then fetching? – शेखर Jan 07 '13 at 06:24
  • @Vogel612 :Thanks , I use .net 4.5... i use `databind()` but don't refresh. – Niloo Jan 07 '13 at 06:35
  • @krshekhar: Yes, when i use pointer, repeater have two item but show one, don't refresh :( – Niloo Jan 07 '13 at 06:36
  • are you using update panel? – शेखर Jan 07 '13 at 06:39
  • @krshekhar : yes i use :( – Niloo Jan 07 '13 at 06:44
  • Then it looks like it is an update panel issue, not a repeater issue. try putting a breakpoint on the `LikeRepeater.DataSource = ` in the click event. Check how many items are returned. I'll venture a guess that it is more than one. – Shai Cohen Jan 07 '13 at 18:56

2 Answers2

0

your datasource is updated ParentLikeButton_Click event but on page load event you set old datasource. so every time you add data might be updated but from page load it takes old data so you need to bind data in if(!isPostback) condition like this in page load event check condition if(!IsPostBack) {bind data here for first time}

Sumit
  • 196
  • 1
  • 8
-2
  1. add "LikeRepeater.DataSource = null" before Setting its
Vincent
  • 11