ASP.NET Gridview 更新功能
当将 SqlDataSource 控件分配给 Gridview 的 DataSourceID 时,ASP.NET 中的 Gridview 控件提供更新功能,但是,当以编程方式将代码级 SqlDataSource 分配给 DataSource 时,内置的更新功能就会消失,您必须自己推出更新功能。为什么?这里有什么区别,因为我们所做的只是直接引用 SqlDataSource,而不是通过 ID?为什么GridView仍然无法利用SqlDataSource UpdateCommand?
The Gridview control in ASP.NET provides updating capabilities when assigning a SqlDataSource control to the Gridview's DataSourceID, however when programmatically assigning a code level SqlDataSource to DataSource, the built-in updating capabilities go away and you are forced to roll your own. Why? What is the difference here, since all we're doing is referring to the SqlDataSource directly, instead of by ID? Why can the GridView still not take advantage of the SqlDataSource UpdateCommand?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,第一种情况,它有 2 个本机控件。网络和数据。您可以通过 VS.NET 的可视化和配置工具执行 RAD。 MS确保该框架可以允许这种可视化控件与数据控件在CRUD方面自动耦合。
第二种情况,当您拥有自己的 SqlDataSource(它不是数据控件之一)时,您就得靠自己了。就是这样。我也希望有人能告诉我们解决方案。
我的2美分。
Well, the first case, it has 2 native controls. Web and Data. You can perform RAD via VS.NET via their visual and configuration tools. MS ensure that the framework can allow such visual controls to data controls coupling in the aspect of CRUD automatically.
Second case, when you have your own SqlDataSource which is not one of the data controls, you are on your own. That's how it is. I hope someone can tell us a solution for it too.
my 2 cents.
我发现可以以编程方式创建 SqlDataSource,为其指定 ID,并按如下方式分配属性,以允许正确映射内置编辑:
I've discovered that it's possible to programmatically create a SqlDataSource, give it an ID, and assign the properties as follows to allow the built in editing to be mapped properly: