Editable Repeater

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();
 
K

Karl Seguin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top