Click here to Skip to main content
Sign Up to vote bad
good
See more: C#ASP.NETSQL2008
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:59


1 solution

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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 498
1 Arun Vasu 275
2 Maciej Los 273
3 Mahesh Bailwal 264
4 Aarti Meswania 175
0 Sergey Alexandrovich Kryukov 9,660
1 OriginalGriff 7,329
2 CPallini 3,968
3 Rohan Leuva 3,339
4 Maciej Los 2,851


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid