ASP.net monitor all cells where the cell value has been changed

Murray Brown
Murray Brown used Ask the Experts™
on
Hi

I have a GridView which has 30 template textbox columns, 4 of which are shown below.
They go from D1 through to  D30
I want detect all cells or text boxes where the value has changes when I click a button
How do I monitor and maintain a record of all cells that are changed?

   <asp:TemplateField HeaderText="D1" Visible="false" ItemStyle-Wrap="true" >
                           <ItemTemplate>
                                <asp:Textbox ID="D1" runat="server"  Visible="true" Width="20"></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>
                      <asp:TemplateField HeaderText="D2" Visible="false" ItemStyle-Wrap="true" >
                           <ItemTemplate>
                                <asp:Textbox ID="D2" runat="server"  Visible="true" Width="20" ></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>
                     <asp:TemplateField HeaderText="D3" Visible="false" ItemStyle-Wrap="true">
                           <ItemTemplate>
                                <asp:Textbox ID="D3" runat="server"  Visible="true" Width="20" ></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>
                      <asp:TemplateField HeaderText="D4" Visible="false" ItemStyle-Wrap="true" >
                           <ItemTemplate>
                                <asp:Textbox ID="D4" runat="server"  Visible="true" Width="20" ></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Developer User Interface
Commented:
You may want to use a third-party control like the Infragistics grid(haven’t used it in a while). Coz Maintaining that much of code manually might be a big task. If u still want to do it, you would have to add a hiddenfield for each of the textboxes.
Then add a onkeydown event to the textbox and add a javascript that will set a value of true in the hiddenfield if the value has changed.

Then when u submit loop through the grid and look for all hiddenfields that have value true and if true find the corresponding textbox.

Are you looking to save only the values that have changed to the database?
Murray BrownASP.net/VSTO Developer

Author

Commented:
Thanks for the help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial