Click here to Skip to main content
11,495,524 members (67,051 online)
Rate this: bad
good
Please Sign up or sign in to vote.
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 4-Feb-13 0:59am

1 solution

Rate this: bad
good
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?
  Permalink  

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

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 265
3 Nakul Chaudhari 236
4 Sergey Alexandrovich Kryukov 230
0 Sergey Alexandrovich Kryukov 10,322
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,889
3 Maciej Los 3,422
4 Richard Deeming 2,560


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2015
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