Click here to Skip to main content
13,148,503 members (53,040 online)
Rate this:
Please Sign up or sign in to vote.
See more: , +
there are 50 text boxes in my code. i want to update only the edited text box values in sql. Is there any code in c# to find how many text box values user has edited out of 50?
Posted 3-Feb-13 23:59pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

No. The easiest way is to use the Tag property. Set all of your textboxes Tags to either a false, or the starting string, and then:
If you use the Tag as a bool, handle the Textboxes.TextChanged Event and set them all to the same method:
private void MyTextBoxes_TextChanged(object sender, EventArgs e)
    TextBox tb = sender as TextBox;
    if (tb != null)
        tb.Tag = true;
You can then look at the tags when you save and decide if it needs to be updated.

If you use a string, then just compare the current value against the Tag value and only save if different.

Why are you using 50 textboxes? Wouldn't a grid of some form be a better solution?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170924.2 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100