Editable Repeater

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

Guest

Hi, I have a repeater in which all rows are editable together (there is one
Save button at the top of the page).

When the page loads with the repeater populated, I change the value in one
of the textboxes and click on save. Instead of taking the newly entered
value I record the original value of the textbox. The code is below, thanks
for your help in advance:

private void lkbSave_Click(object sender, System.EventArgs e)
{

for(int count=0;count<ScoresRepeater.Items.Count;count++)
{
objReferralTestScore.TestScore[-1,
count].AssessmentInstanceScore=((TextBox)ScoresRepeater.Items[count].FindControl("tbxScore")).Text;
}

objReferralTestScore.Write();
 
Jack:
My guess is that you are rebinding the control on postback, which is
overwriting the newly entered data. You need to wrap your binding code in a
if (!Page.IsPostBack){ }

if (!Page.IsPostBack){
ScoresRepeater.DataSource = GetAllScores();
ScoresRepeater.DataBind();
}

Remember, the Page_Load event occurs beforethe Save_Click event (even on
postback)....so if you don't do this you are rebinding the old data to the
repeater (it hasn't been saved yet) and thus overwriting the edited change.

Karl
 
Back
Top