...更新数据库值 [英] ...update database value
问题描述
我有一个< asp:formview xmlns:asp =#unknown">绑定到SQL数据库,并且,我试图找出如何从FormView(通过SQL)读取条目,并将其值转换为变量,然后将其用于SQL Update语句中. .
此外,文本框应从readonly = false切换为readonly = true.在此处.
不幸的是,由于表单上的按钮存在问题,我无法使用相同的FormView用于SQL语句,尽管在< formview>中使用的命令是理想的,但无法在< formview>中显示;元素.
:confused:
I have an <asp:formview xmlns:asp="#unknown"> that is bound to an SQL Database, and, I am trying to figure out how to read an entry from the FormView (through SQL), and, translate its value to a variable, which is then going to be used in an SQL Update Statement.
Moreover, the textboxes should switch from readonly = false to readonly = true. The sequence of events from a user point of view is explained within the screenshots; source code is available here.
Unfortunately I could not use the same FormView for SQL Statements, because of a problem with the buttons on the form, that could not be displayed within <formview>, although it would have been ideal to use the commands used within the <formview> element.
:confused:
推荐答案
FormView
基本上用于显示来自数据源的单个记录的值.
仅在将数据源绑定到FormView
控件之后,才会呈现ItemTemplate
中的控件.
在BindFormView()
方法中,您没有将任何数据源绑定到FormView
控件.因此myFormView.FindControl("myTextbox")
始终不返回任何内容.
尝试将数据绑定到FormView
之后.它将返回Textbox控件.
FormView
is basically used to display the values of a single record from a data source.
The controls in theItemTemplate
will be rendered only after binding a data source to theFormView
control.
In theBindFormView()
method, you didn''t bind any data source to theFormView
control. ThereforemyFormView.FindControl("myTextbox")
returns always nothing.
Try after data binding to theFormView
. It will return the Textbox control.
HI
您可以从formview中读取条目,如下所示,用于TextBox控件
HI
You can read the entry from the formview as shown below for TextBox control
TextBox txtPaidAmount = (TextBox)FormView.FindControl(txtTextBox1);
这篇关于...更新数据库值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!