在db中更新asp.net中的字段 [英] updating fields from asp.net in db

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

问题描述

我停留在场景中,我有显示记录,如果我想编辑然后我点击编辑它进入编辑模式,将UserID传递到另一个页面,编辑页面显示文本框,下拉列表要编辑,让我想我想要编辑6个中的3个字段,然后如何保留我未插入或选择任何内容的旧值,因为如果我不选择/放置任何值,那么它将在数据库中将null放入该列,因此如何防止和更新只有所需的字段?

解决方案

你必须将所有6个旧值传递给下一页

并绑定所有6个字段下拉列表文本框,而不是全部更新。


从问题中,您似乎对页面上的编辑功能感到困惑。通常,编辑页面应填充现有值。因此,除非已被用户删除,否则不会将非更改字段作为NULL插入到数据库中。


i am stuck in scenario, i have display record, if i want to edit then i click edit and it goes into edit mode, passing UserID to another page, EDIT page shows Textboxes, dropdowns to be edited, lets suppose i want to edit 3 fields out of 6 then how to keep old values for which i am not inserting or selecting anything because if i don't select/put any value then it will put null into that column in DB, so how to prevent and update only desired fields ?

解决方案

You have to pass all the 6 old values to next page
and bind all 6 field dropdownns text box , than updated all .


From the Question , it seems that you are bit confused on the Edit functionality on the Page. Usually , Edit Page should be Populated with the Existing Value . So there is no question of inserting Non Changed fields as NULL into the DB unless its been removed by the User.


这篇关于在db中更新asp.net中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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