我将查询返回的记录填充至一个dataset,然后用一行一行的文本框显示表中的内容,比如有三个字段,那我一行放三个文本框,这样没问题可以显示出来,
If dtfixedorder.Tables(0).Rows.Count - r = 1 Then
mcode = dtfixedorder.Tables(0).Rows(r)("code")
mbigp = dtfixedorder.Tables(0).Rows(r)("bigp")
msmlp = dtfixedorder.Tables(0).Rows(r)("smlp")
tb11.Text = mcode : tb12.Text = mbigp : tb13.Text = msmlp
End If
然后,当用户在文本框中更改了数据,点UPDATE按钮,我就要把数据更新回数据库
If tb11.Text <> "" AndAlso IsNumeric(tb12.Text) AndAlso IsNumeric(tb13.Text) Then
a = Convert.ToDecimal(tb12.Text)
b = Convert.ToDecimal(tb13.Text)
'问题出在这,即使你在文本框中改了数据,调用更新的时候,得到的还是原旧数据,所以更新回去还是原数据没变,是不是跟上面的绑定有关?
Call mydatabase.addfixedorder(uid, tb11.Text, a, b)
End If
我如果在旁边加三个新文本框,没和dataset的字段相连就可以
我的问题很简单,就是用文本框显示出表里的每条记录,当用户在文本框中更改了数据,点更新按钮进行更新,请大家帮帮我,在线等~~~~~~~~~
If dtfixedorder.Tables(0).Rows.Count - r = 1 Then
mcode = dtfixedorder.Tables(0).Rows(r)("code")
mbigp = dtfixedorder.Tables(0).Rows(r)("bigp")
msmlp = dtfixedorder.Tables(0).Rows(r)("smlp")
tb11.Text = mcode : tb12.Text = mbigp : tb13.Text = msmlp
End If
然后,当用户在文本框中更改了数据,点UPDATE按钮,我就要把数据更新回数据库
If tb11.Text <> "" AndAlso IsNumeric(tb12.Text) AndAlso IsNumeric(tb13.Text) Then
a = Convert.ToDecimal(tb12.Text)
b = Convert.ToDecimal(tb13.Text)
'问题出在这,即使你在文本框中改了数据,调用更新的时候,得到的还是原旧数据,所以更新回去还是原数据没变,是不是跟上面的绑定有关?
Call mydatabase.addfixedorder(uid, tb11.Text, a, b)
End If
我如果在旁边加三个新文本框,没和dataset的字段相连就可以
我的问题很简单,就是用文本框显示出表里的每条记录,当用户在文本框中更改了数据,点更新按钮进行更新,请大家帮帮我,在线等~~~~~~~~~
http://chs.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid6.src
条件没通过
你需要把下面三个控件取值的过程放到if(!Page.IsPostBack)中,如下:
if(!Page.IsPostBack)
{
tb11=mcode
tb12=mbigp
tb13=。。}
当然上面试C#的代码,你自己修改为Vb的吧
if(!IsPostBack)
{
这里是你载入页面的帮定的数据代码.
}
执行更新操作后,看看数据库的记录更新了吗?
如果没有更新,那就跟踪看看原因.
如果数据库更新了,而界面没有更新那可能是在页面刚打开的时候初始化的时候的问题.
不要把初始化写在if(!IsPostBack)中,而是直接写在Page_load中.
If dtfixedorder.Tables(0).Rows.Count - r = 1 Then
mcode = val(dtfixedorder.Tables(0).Rows(r)("code"))
mbigp = val(dtfixedorder.Tables(0).Rows(r)("bigp"))
msmlp = val(dtfixedorder.Tables(0).Rows(r)("smlp"))
tb11.Text = mcode : tb12.Text = mbigp : tb13.Text = msmlp
End If看看有没有效果,譬如说特殊字符之类的问题
修改如下:if ispostback is nothing then
If dtfixedorder.Tables(0).Rows.Count - r = 1 Then
mcode = dtfixedorder.Tables(0).Rows(r)("code")
mbigp = dtfixedorder.Tables(0).Rows(r)("bigp")
msmlp = dtfixedorder.Tables(0).Rows(r)("smlp")
tb11.Text = mcode : tb12.Text = mbigp : tb13.Text = msmlp
End If
end if主要是防止每次页面提交时,都重复执行一次上述文本框的赋值过程.如此,修改后的值就可正确取到.
If (Not IsPostBack) Then
End If
谢谢大家!~~,祝大家身体健康,学业有成,事业进步!