datagrid update命令 [英] datagrid update command

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

问题描述

我写了一个用datagrid updatecommand来更新datagrid的代码但是我在更新后无法得到更新的值

即代码


private void DataGrid1_UpdateCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)

TextBox temp

temp =(TextBox)e.Item.Cells [0] .Controls [ 0]

String str = temp.Text;


str总是返回单元格的旧值(在更新之前)

你能不能告诉我什么是错误的什么?

thnx alo

i wrote a code to update datagrid with the datagrid updatecommand but i cant get the updated values after being update
that is the code

private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
TextBox temp
temp=(TextBox)e.Item.Cells[0].Controls[0]
String str=temp.Text;

str always returnt the old value of the cell (before being updated)
would u plz tell me about whats wrong i m doin
thnx alo

推荐答案

更新后,通过在更新代码的末尾附加一个选择的

SQL语句来查询数据源中的数据,或运行一个存储过程,

再次将新数据拉下来。 br />
下面的代码并没有显示你实际更新数据的方式,只是

如何从输入中获取更改后的数据。

abdoly&quo吨; < AB **** @ yahoo.com>在消息中写道

新闻:EA ********************************** @ microsof t.com ...
After the update, query the data from the data source by appending a select
SQL statement to the end of your update code or run a stored procedure that
pulls the fresh data down again.
Your code below doesn''t show how you are actually updating the data, just
how you are getting the changed data from the input.
"abdoly" <ab****@yahoo.com> wrote in message
news:EA**********************************@microsof t.com...
我写了一个用datagrid updatecommand来更新datagrid的代码,但是i
在更新之后无法得到更新的值,即代码

private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e){TextBox temp;
temp =(TextBox)e.Item.Cells [0] .Controls [0];
字符串str = temp.Text;
}
str总是返回单元格的旧值(在更新之前)
你能不能告诉我什么是错误的我在做什么? /> thnx alot
i wrote a code to update datagrid with the datagrid updatecommand but i cant get the updated values after being updated that is the code

private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e){ TextBox temp;
temp=(TextBox)e.Item.Cells[0].Controls[0];
String str=temp.Text;
}
str always returnt the old value of the cell (before being updated)
would u plz tell me about whats wrong i m doing
thnx alot






----- Scott M.写道:----


更新后,通过在更新代码的末尾附加选择
SQL语句或运行存储过程来查询数据源中的数据br />
再次提取新数据

下面的代码并没有显示你是怎么回事实际更新数据,jus

如何从输入中获取更改后的数据

" abdoly" < AB **** @ yahoo.com>在消息中写道

新闻:EA ********************************** @ microsof t.com ..


----- Scott M. wrote: ----

After the update, query the data from the data source by appending a selec
SQL statement to the end of your update code or run a stored procedure tha
pulls the fresh data down again
Your code below doesn''t show how you are actually updating the data, jus
how you are getting the changed data from the input
"abdoly" <ab****@yahoo.com> wrote in messag
news:EA**********************************@microsof t.com..
我写了一个用datagrid updatecommand来更新datagrid的代码,但
在更新后得到更新的值,即cod
i wrote a code to update datagrid with the datagrid updatecommand but cant get the updated values after being update that is the cod
private void DataGrid1_UpdateCommand(object source
private void DataGrid1_UpdateCommand(object source


System.Web.UI.WebControls.DataGridCommandEventArgs e)TextBox temp
temp =(TextBox)e.Item.Cells [0] .Controls [0]
字符串str = temp.Text

str总是返回单元格的旧值(在更新之前
你会告诉我什么是错误的我在做什么
thnx alo

System.Web.UI.WebControls.DataGridCommandEventArgs e) TextBox temp
temp=(TextBox)e.Item.Cells[0].Controls[0]
String str=temp.Text

str always returnt the old value of the cell (before being updated
would u plz tell me about whats wrong i m doin
thnx alo



感谢您的关心,但我的问题是我需要获取在datagrid文本中写入的新值来更新数据源,无论我如何更新数据,我只是需要知道如何获取新值,即使我想在它上面预览

thnk


thanks for ur care , but my problem is that i need to get the new value wrote in the datagrid text to update the data source with it,whatever how i update the data, i just need to know how to fetch the new value even if i want to preview it on the for
thnk


这是代码那将获取用户输入的数据并将其写回网格绑定的

数据集并重新绑定网格。这就是你没有做的事情。您必须将网格重新绑定到已更改的数据集,以便

网格显示新内容。

Private Sub dg_UpdateCommand(ByVal source As Object ,ByVal e As

System.Web.UI.WebControls.DataGridCommandEventArgs)处理dg.UpdateCommand


''" FindControl"只接受控件的名称

Dim editObject As Object =

CType(e.Item.Cells(0).FindControl(" ControlNameHere"),ControlTypeHere )

ds.Tables(0).Rows(e.Item.ItemIndex).Item(" CustID")= edittext.Text


''对每一列重复上述步骤(和网格中的控件)


''退出编辑模式

dg.EditItemIndex = -1


''更新DataGrid

dg.DataBind()

End Sub

" abdoly" < AB **** @ yahoo.com>在消息中写道

news:87 ********************************** @ microsof t.com ...
Here is code that will grab the user inputted data and write it back to the
DataSet that the grid is bound to and rebind the grid. This is what you are
not doing. You must re-bind the grid to the changed dataset in order for
the grid to show the new contents.

Private Sub dg_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles dg.UpdateCommand

'' "FindControl" will only accept the name of a control
Dim editObject As Object=
CType(e.Item.Cells(0).FindControl("ControlNameHere "), ControlTypeHere)
ds.Tables(0).Rows(e.Item.ItemIndex).Item("CustID") = edittext.Text

'' Repeat the above steps for each column (and control in the grid)

''Get out of edit mode
dg.EditItemIndex = -1

''Update the DataGrid
dg.DataBind()
End Sub
"abdoly" <ab****@yahoo.com> wrote in message
news:87**********************************@microsof t.com...


----- Scott M.写道:-----

更新后,查询来自数据源的数据,方法是将
select SQL语句附加到更新代码的末尾,或运行存储的
过程,再次将新数据拉下来。

您的代码下面没有显示你实际更新数据的方式,
只是你如何从输入中获取更改后的数据。

" abdoly" < AB **** @ yahoo.com>在消息中写道
新闻:EA ********************************** @ microsof t.com。 ..


----- Scott M. wrote: -----

After the update, query the data from the data source by appending a select SQL statement to the end of your update code or run a stored procedure that pulls the fresh data down again.
Your code below doesn''t show how you are actually updating the data, just how you are getting the changed data from the input.
"abdoly" <ab****@yahoo.com> wrote in message
news:EA**********************************@microsof t.com...
>我写了一个代码来更新datagrid与datagrid updatecommand
> i wrote a code to update datagrid with the datagrid updatecommand


,但我无法在更新后获得更新的值

but i cant get the updated values after being updated

>这是代码
>> private void DataGrid1_UpdateCommand(object source,
>> private void DataGrid1_UpdateCommand(object source,

System.Web.UI.WebControls.DataGridCommandEventArgs e){

System.Web.UI.WebControls.DataGridCommandEventArgs e){

> TextBox temp;
> temp =(TextBox)e.Item.Cells [0] .Controls [0];
> String str = temp.Text;
> }
> str总是返回细胞的旧值(在更新之前)
>你会告诉我有什么不对的吗
> thnx很多
>
> TextBox temp;
> temp=(TextBox)e.Item.Cells[0].Controls[0];
> String str=temp.Text;
> }
> str always returnt the old value of the cell (before being updated)
> would u plz tell me about whats wrong i m doing
> thnx alot
>



感谢您的关心,但我的问题是我需要获得新的



thanks for ur care , but my problem is that i need to get the new



值写道在datagrid文本中用它来更新数据源,无论是什么

我如何更新数据,我只需知道如何获取新值即使

如果我想要在表格上预览


value wrote in the datagrid text to update the data source with it,whatever
how i update the data, i just need to know how to fetch the new value even
if i want to preview it on the form thnks



这篇关于datagrid update命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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