更新sql中的Textbox值 [英] Update Textbox values in sql

查看:69
本文介绍了更新sql中的Textbox值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码中有50个文本框。我想只更新sql中编辑的文本框值。 c#中是否有任何代码可以查找用户编辑了多少个文本框值?

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?

推荐答案

否。最简单的方法是使用Tag属性。将所有文本框标记设置为false或起始字符串,然后:

如果将标记用作bool,请处理Textboxes.TextChanged事件并将它们全部设置为相同的方法:

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;
        }
    }

您可以在保存时查看标签并确定是否需要更新。



如果您使用字符串,那么只需将当前值与Tag值进行比较,只有在不同时保存。



为什么使用50个文本框?某种形式的网格不是更好的解决方案吗?

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?


这篇关于更新sql中的Textbox值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆