GridView更新问题 [英] GridView update problem

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

问题描述

您好,

我有一个Gridview控件(.net 2.0),我无法获取

更新按钮来触发任何类型的事件或预成型更新。

数据表基于一个连接,所以我不知道这是什么导致了

的行为。似乎更新按钮至少应该是


单击编辑按钮时,网格进入编辑模式并取消

按钮使网格退出编辑模式。所以,我没有得到诀窍

这里。

我已启用通过FooterRow添加记录。

我使用联接的原因是允许在联接字段中进行排序。我知道我可以放弃连接,添加一个模板字段然后

在RowDataBound期间填充它但是那个排序不会工作......


有什么想法吗?


谢谢

SAL

解决方案

嗨SAL,


从您的描述中,您遇到一些问题需要获取更新

函数在GridView中工作,对吗?


至于更新不起作用,是否意味着如果你点击更新,按钮,

页面没有回发或页面回发但是数据库

更新命令没有生效?


另外,你如何在GridView中实现编辑/更新,你是直接使用SqlDataSource的双向数据绑定来自动执行更新吗?

你手动使用代码更新数据库(更新事件时)?

一般来说,对于这样的问题,我首先会注册RowUpdating。事件

的Gridview(确保它被触发)然后检查所有参数(通过

事件Argument参数)来查看列数据用户是否已输入

已在参数集中正确提供:


===================

protected void GridView1_RowUpdating(object sender,

GridViewUpdateEventArgs e)

{

//e.Keys;

//e.NewValues;

// e.OldValues;

...................

======================


如果有什么我省略的,请感受免费让我知道。


真诚的,


Steven Cheng


微软MSDN在线支持领导

让客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:
ms****@microsoft.com


========================================== ========

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。


注意:MSDN托管新闻组支持服务是针对非紧急问题

如果社区或微软支持人员在1个工作日内做出初步回复是可以接受的。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========

此帖子按原样提供。没有保证,也没有赋予任何权利。


--------------------


>来自:" SAL" < SA*@nospam.nospam>
主题:GridView更新问题
日期:2008年7月8日星期二14:07:56 -0700


>您好,
我有一个Gridview控件(.net 2.0),我无法通过
更新按钮触发任何类型的事件或执行更新。
数据表基于连接,所以我不知道这是什么导致了
行为。似乎更新按钮至少应该做什么。
当点击编辑按钮时,网格进入编辑模式,



取消


>按钮使网格退出编辑模式。所以,我不知道这里有什么诀窍。
我已经启用了通过FooterRow添加记录。
我使用连接的原因是允许排序在加入的领域。我知道我可以放下连接,添加一个模板字段然后在RowDataBound中填充它但是然后排序就不行了......

任何想法?

谢谢
SAL


嗨史蒂文。据我所知,它甚至没有做回发。如果一个事件

被解雇,我至少可以手动更新记录。很高兴

让它自动更新但是通过双向绑定。


我已经通过一个被绑定的objectdatasource实现了双向绑定到一个

业务对象,业务对象正在使用一个使用设计器创建的表适配器




S


" Steven Cheng [MSFT]" < st ***** @ online.microsoft.com写信息

新闻:e5 ************** @ TK2MSFTNGHUB02.phx.gbl ...


你好SAL,


根据你的描述,你遇到一些问题需要更新

函数在GridView中工作,对吗?


至于更新不起作用,是否意味着如果你点击更新按钮,

页面没有回发或页面回发但是数据库

更新命令没有生效?


另外,你如何在GridView中实现编辑/更新,你是直接使用SqlDataSource的双向数据绑定来自动执行更新吗?

你手动使用代码更新数据库(更新事件时)?

一般来说,对于这样的问题,我首先会注册RowUpdating。事件

的Gridview(确保它被解雇)然后检查所有参数

(通过

事件Argument参数)来查看是否用户输入的列数据

已在参数集中正确提供:


================ ===

protected void GridView1_RowUpdating(对象发送者,

GridViewUpdateEventArgs e)

{

// e。钥匙;

//e.NewValues;

// e.OldValues;

............ ......

======================


如果有的话我省略了什么,请随时告诉我。


此致,


Steven Cheng


Microsoft MSDN在线支持主管


让客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:
ms****@microsoft.com


========================================== ========

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。


注意:MSDN托管新闻组支持服务是针对非紧急问题

如果社区或微软支持人员在1个工作日内做出初步回复是可以接受的。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========

此帖子按原样提供。没有保证,并且没有

权利。


--------------------


>>来自:" SAL" < SA*@nospam.nospam>
主题:GridView更新问题
日期:2008年7月8日星期二14:07:56 -0700


>>您好,
我有一个Gridview控件(.net 2.0),我无法通过
更新按钮触发任何类型的事件或执行更新。
数据表基于连接,所以我不知道这是什么导致了
行为。似乎更新按钮至少应该做什么。
当点击编辑按钮时,网格进入编辑模式,



取消


>>按钮使网格退出编辑模式。所以,我不知道这里有什么诀窍。
我已经启用了通过FooterRow添加记录。
我使用连接的原因是允许排序在加入的领域。我知道我可以放下连接,添加一个模板字段然后在RowDataBound中填充它但是然后排序就不行了......

任何想法?

谢谢
SAL



感谢您的回复SAL,


这似乎出乎意料,因为只要更新

按钮被正确放置(通过编辑/更新命令字段),回发就应该有效。是否可以通过

一些简化的数据源进行修改?你可以寄给我一份简化的副本,这样我也可以在我身边测试它。我的电子邮件是


" stcheng" + @ +" microsoft.com"


此致,


Steven Cheng


Microsoft MSDN在线支持主管

让客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:
ms****@microsoft.com

--------------------


> From:" SAL" < SA*@nospam.nospam>
参考文献:< Oh ************** @ TK2MSFTNGP06.phx.gbl>



< e5 ************** @ TK2MSFTNGHUB02.phx.gbl>


>主题:Re:GridView更新问题
日期:星期三,2008年7月9日09:52:04 -0700


>
嗨史蒂文。据我所知,它甚至没有做回发。如果



事件


>正在解雇,我至少可以手动更新记录。这将是很好的





>让它通过双向绑定自行更新。

我已经通过objectdatasource实现了双向绑定,绑定到



a


>业务对象和业务对象使用的是使用设计器创建的表适配器。

Steven Cheng [MSFT] QUOT; < st ***** @ online.microsoft.com写信息
新闻:e5 ************** @ TK2MSFTNGHUB02.phx.gbl ...


>您好SAL,

从您的描述中,您遇到一些问题,以使GridView中的更新功能正常工作,正确吗?

至于更新不起作用,是否意味着如果你点击更新按钮,页面没有回传或页面回发但数据库更新命令没有生效?

另外,如何实现编辑/更新在GridView中,您是否直接使用SqlDataSource的双向数据绑定来自动执行更新





>你手动使用代码更新数据库(更新事件时)?
一般来说,对于这样的问题,我会先注册" RowUpdating" Gridview的事件(确保它被解雇)然后检查所有参数
(通过事件Argument参数)查看列数据用户是否



输入


>已在参数集合中正确提供:

===================
protected void GridView1_RowUpdating(对象发送者,
GridViewUpdateEventArgs e)
{
//e.Keys;
//e.NewValues;
// e.OldValues;
..................
======================

如果有任何遗漏,请随时告诉我。

此致,


Hello,
I have a Gridview control (.net 2.0) that I''m having trouble getting the
Update button to fire any kind of event or preforming the update. The
datatable is based on a join so I don''t know if that''s what''s causing the
behavior or not. It seems like the Update button should at least do
something.
When the Edit button is clicked, the grid goes into Edit mode and the Cancel
button takes the grid out of Edit mode. So, I don''t get what the trick is
here.
I''ve enabled adding records via the FooterRow.
The reason I''m using a join is to allow sorting on the joined in field. I
know that I could drop kick the join, add in a template field and then
populate it during RowDataBound but then the sort won''t work...

Any ideas?

Thanks
SAL

解决方案

Hi SAL,

From your description, you''re encountering some problem to get the update
function in GridView to work, correct?

As for the Updating not work, do you means if you click "Update" button,
the page doesn''t postback or the page does postback but the database
updating commands are not taking effect?

Also, how do you implement the edit/update in GridView, are you directly
use SqlDataSource''s two-way databinding to automatically perform update or
you manually use code to update the database (when updating event fires)?
Generally, for such issue, I would first register the "RowUpdating" event
of the Gridview(ensure it get fired) and then check all the parameters (via
the event Argument parameter) to see whether the column data user entered
have been supplied correctly in the parameter collection:

===================
protected void GridView1_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
//e.Keys;
//e.NewValues;
// e.OldValues;
...................
======================

If there is anything I omit, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

>From: "SAL" <SA*@nospam.nospam>
Subject: GridView update problem
Date: Tue, 8 Jul 2008 14:07:56 -0700

>Hello,
I have a Gridview control (.net 2.0) that I''m having trouble getting the
Update button to fire any kind of event or preforming the update. The
datatable is based on a join so I don''t know if that''s what''s causing the
behavior or not. It seems like the Update button should at least do
something.
When the Edit button is clicked, the grid goes into Edit mode and the

Cancel

>button takes the grid out of Edit mode. So, I don''t get what the trick is
here.
I''ve enabled adding records via the FooterRow.
The reason I''m using a join is to allow sorting on the joined in field. I
know that I could drop kick the join, add in a template field and then
populate it during RowDataBound but then the sort won''t work...

Any ideas?

Thanks
SAL


Hi Steven. As far as I can tell, it''s not even doing a postback. If an event
was firing, I could at least manually update the record. It would be nice to
have it update itself however via two-way binding.

I''ve implemented two way binding via an objectdatasource which is bound to a
business object and the business object is using a table adapter that was
created using the designer.

S

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:e5**************@TK2MSFTNGHUB02.phx.gbl...

Hi SAL,

From your description, you''re encountering some problem to get the update
function in GridView to work, correct?

As for the Updating not work, do you means if you click "Update" button,
the page doesn''t postback or the page does postback but the database
updating commands are not taking effect?

Also, how do you implement the edit/update in GridView, are you directly
use SqlDataSource''s two-way databinding to automatically perform update or
you manually use code to update the database (when updating event fires)?
Generally, for such issue, I would first register the "RowUpdating" event
of the Gridview(ensure it get fired) and then check all the parameters
(via
the event Argument parameter) to see whether the column data user entered
have been supplied correctly in the parameter collection:

===================
protected void GridView1_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
//e.Keys;
//e.NewValues;
// e.OldValues;
..................
======================

If there is anything I omit, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------

>>From: "SAL" <SA*@nospam.nospam>
Subject: GridView update problem
Date: Tue, 8 Jul 2008 14:07:56 -0700

>>Hello,
I have a Gridview control (.net 2.0) that I''m having trouble getting the
Update button to fire any kind of event or preforming the update. The
datatable is based on a join so I don''t know if that''s what''s causing the
behavior or not. It seems like the Update button should at least do
something.
When the Edit button is clicked, the grid goes into Edit mode and the

Cancel

>>button takes the grid out of Edit mode. So, I don''t get what the trick is
here.
I''ve enabled adding records via the FooterRow.
The reason I''m using a join is to allow sorting on the joined in field. I
know that I could drop kick the join, add in a template field and then
populate it during RowDataBound but then the sort won''t work...

Any ideas?

Thanks
SAL



Thanks for your reply SAL,

That seems unexpected since the postback should work as long as the update
button is put correctly(via edit/update command field). Is it reproable via
some simplified data source? You can send me a simplified copy so that I
can also test it on my side. My email is

"stcheng" + @ + "microsoft.com"

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
--------------------

>From: "SAL" <SA*@nospam.nospam>
References: <Oh**************@TK2MSFTNGP06.phx.gbl>

<e5**************@TK2MSFTNGHUB02.phx.gbl>

>Subject: Re: GridView update problem
Date: Wed, 9 Jul 2008 09:52:04 -0700

>
Hi Steven. As far as I can tell, it''s not even doing a postback. If an

event

>was firing, I could at least manually update the record. It would be nice

to

>have it update itself however via two-way binding.

I''ve implemented two way binding via an objectdatasource which is bound to

a

>business object and the business object is using a table adapter that was
created using the designer.

S

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:e5**************@TK2MSFTNGHUB02.phx.gbl...

>Hi SAL,

From your description, you''re encountering some problem to get the update
function in GridView to work, correct?

As for the Updating not work, do you means if you click "Update" button,
the page doesn''t postback or the page does postback but the database
updating commands are not taking effect?

Also, how do you implement the edit/update in GridView, are you directly
use SqlDataSource''s two-way databinding to automatically perform update

or

>you manually use code to update the database (when updating event fires)?
Generally, for such issue, I would first register the "RowUpdating" event
of the Gridview(ensure it get fired) and then check all the parameters
(via
the event Argument parameter) to see whether the column data user

entered

>have been supplied correctly in the parameter collection:

===================
protected void GridView1_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
//e.Keys;
//e.NewValues;
// e.OldValues;
..................
======================

If there is anything I omit, please feel free to let me know.

Sincerely,


这篇关于GridView更新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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