文本框在ASP.NET中输入数据所面临的问题 [英] problem facing with Textboxes entering data in ASP.NET
问题描述
Hello Frnds!
正在使用c#SqlServer 2005处理asp.net项目。
我的网页上有10个文本框和一个提交按钮...这用于保存数据库中输入的数据....它的工作正常。
我的要求是:
来自10个文本框我将只输入7个文本框....前3个文本框将照常输入每个条目。
只有一次我会进入前3个texbox ...而nextTime我将进入其他7个文本框..我不想进入前3个tbox。
前3个文本框数据对所有人来说都是通用的。
所以请帮我怎么做?
谢谢
在你的页面加载事件中,只要它是回发就设置文本框的值 - 所以第一次它们将为空并随后将值设置为先前提交的值
我假设前3个文本框将具有公共值或默认值。如果是这种情况,为什么你甚至需要网页中的那3个文本框?
只保留7个文本框,输入您想要的数据。提交时包括在接下来的7个文本框中输入的前3个默认值和值,然后将它们保存到数据库中。
这就是你如何管理它或你想要它的方式。我给出代码示例of vb.net
受保护的 Sub btnSendMail_ServerClick( ByVal sender 作为 对象,< span class =code-keyword> ByVal e As System.EventArgs)句柄 btnSendMail .ServerClick
' 在插入数据库之前保存在viewstate中,如下所示
ViewState( txt1)= txtCcMail.Text
' 将您的代码插入到数据库中e
''' ''''''''''
' 一旦插入数据库,将viewstate值分配回受尊重的文本框并清除其他文本框
txttoMail.Text = ViewState( txt1)
结束 Sub
快乐编码
Hello Frnds !
am working on asp.net project using c# SqlServer 2005.
I have 10 Textboxes and a submit button on my webpage...this is use to save the data entered in database....its works fine.
My requirement is :
from total 10 textboxes i will enter only in 7 textboxes.... the first 3 textboxes will be as usual for every entry.
only once i will enter in first 3 texboxes...and nextTime i will enter in other 7 textboxes..i dont want to enter in first 3 tboxes.
the first 3 textboxes data will be common to all.
so please help me how to do this ?
Thanks解决方案In your page load event, set the value of the textboxes whenever it''s a postback - so the first time they will be empty and subsequently you set the values to whatever was submitted previously
I am assuming that first 3 textboxes will have common or default values. If that is the case, why do you even need those 3 textboxes in the webpage?
Keep only 7 textboxes, enter the data you want. While submitting include first 3 default values and values entered in next 7 textboxes, then save them into database.
this is just how you manage it or how you want it.I am give code example of vb.net
Protected Sub btnSendMail_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendMail.ServerClick 'before inserting to database save in viewstate as follows ViewState("txt1") = txtCcMail.Text 'put your code to insert into database '''''''''''''''' 'once you inserted to database assign viewstate value back to respected textbox and clear other textboxes txttoMail.Text = ViewState("txt1") End Sub
Happy coding
这篇关于文本框在ASP.NET中输入数据所面临的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!