Search code examples
asp.net.net-2.0repeater

ASP.NET - Detect Changed Values in a Repeater?


Good Morning,

I have a page with a Repeater. The Repeater typically contains 250 - 500 rows.

The ItemTemplate contains 5 TextBox controls and 1 DropDownList. The user can modify any of these values.

After modifying one or more values (in one or more rows) the user will click the 'Save' button. At this point I want to update the database -- but first I need to identify the rows that have changed.

I've experimented with the TextBox.TextChange event ... but I have 5 TextBox controls per row ... I don't want to update the same item five times ... so I am looking for something better.

It would be great if there was a RepeaterItem.SomeValueChanged event ... but so far I haven't found one! :-)

Anyone have a more 'elegant' solution?

Thank you!

Glen


Solution

  • Have a hidden field to reflect a value which would tell you that something has changed. On initial databinding set its value to 0. Wire some js for the textboxes such that they'll update the hiddenfield with 1. Then on the btn save event you need only be interested only in those items that has 1.