错误:都定义了DataSource和DataSourceID.删除一个定义. [英] Error: Both DataSource and DataSourceID are defined. Remove one definition.

查看:73
本文介绍了错误:都定义了DataSource和DataSourceID.删除一个定义.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我有一个使用SqlDatasource的gridview.现在,我想将数据表用作数据源,同时这样做会产生错误:同时定义了数据源和数据源ID.删除一个定义.

为了解决这个问题,我编写了下面的代码,它们可以正常工作

Hello

I have a gridview for which I have used SqlDatasource. Now, I want to use datatable as a datasource, while doing so it is giving an error: Both DataSource and DataSourceID are defined. Remove one definition.

To resolve it, I have written the following code that is perfectly working

GVBrand.DataSourceID = string.Empty;
GVBrand.DataSource = dt;
GVBrand.DataBind();


我发现,当我单击编辑"或删除"按钮时,它会出现以下错误:
Sys.WebForms.PageRequestManagerServerErrorException:GridView"GridView1"触发了未处理的事件RowEditing.

请帮我,因为我没有解决办法.
预先感谢.


I found that, when I click edit or delete button, then it gives the following error:
Sys.WebForms.PageRequestManagerServerErrorException: The GridView ''GridView1'' fired event RowEditing which wasn''t handled.

Please help me, as I have no solution for that.
Thanks in advance.

推荐答案

这是一个不同的错误.错误消息不言自明.行编辑事件未在后面的代码中处理.处理该事件.
This is a different error. Error message is self explanatory.Row editing event is not handled in the code behind. Handle that event.


GVBrand.DataSourceID = string.Empty;
删除该行即可.
GVBrand.DataSourceID = string.Empty;
remove that line it will work.


这篇关于错误:都定义了DataSource和DataSourceID.删除一个定义.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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