DataGrid和ObjectDataSource将值传递给Update但不传递给Delete [英] DataGrid and ObjectDataSource passes value to Update but not to Delete

查看:56
本文介绍了DataGrid和ObjectDataSource将值传递给Update但不传递给Delete的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我已经设置了 DataGrid 并将其绑定到 ObjectDataSource 。我已经设置了 ObjectDataSource DataObjectTypeName 属性,因此它希望绑定到它正在操作的业务对象。



更新工作正常。但是,当我单击删除时,将调用业务逻辑层中的相应方法,但所有字段都为空。我显然遗漏了一些显而易见的东西,但我似乎没有对我读过的所有例子做任何不同的事情。



有没有人知道我的意思做错了吗?





亲切的愿望~Patrick

Hi,

I have set up a DataGrid and bound it to an ObjectDataSource. I have set the DataObjectTypeName property of the ObjectDataSource, so it expects to bind to the business object it is manipulating.

The Update works fine. When I click Delete, however, the corresponding method in the business logic layer is called, but all the fields are empty. I am clearly missing something obvious, but I don't seem to be doing anything different to all the examples I have read.

Does anyone have any idea what I might be doing wrong?


Kind wishes ~ Patrick

推荐答案

解决这个。我似乎需要设置 DataKeyNames 属性。



所以,我现在可以完成4个CRUD操作中的3个。我以为我回家干了,但现在我无法弄清楚如何从 DataGrid 添加新记录。我是否正确地认为您需要在 DataGrid 的末尾启用空行,因此您可以在某处输入新记录的值?



我尝试通过在屏幕上放置一些单独的文本框来进行操作,在其中输入新记录的字段,但我无法弄清楚如何将这些文本放入 InsertMethod ObjectDataSource 。我想我可以通过创建参数并将它们添加到 InsertParameters 集合来以编程方式执行此操作,但我很惊讶地发现参数类似乎没有属性设定其价值。我如何获得价值呢?



Arghhh ......我为此感到很生气。我读过的每个教程似乎都缺少一些关键信息。请帮忙!





亲切的愿望~Patrick
Solved this one. It seems I needed to set the DataKeyNames property.

So, I can now do 3 of the 4 CRUD operations. I thought I was home and dry, but now I can't figure out how to add a new record from a DataGrid. Am I correct in thinking that you somehow need to enable an empty row at the end of the DataGrid, so you have somewhere to enter the values for the new record?

I tried doing it by having some separate text boxes on the screen, in which to enter the fields for the new record, but I can't figure out how to get these into the InsertMethod of the ObjectDataSource. I thought I could do this programmatically by creating parameters and adding them to the InsertParameters collection, but I was surprised to find that the Parameter class doesn't seem to have a property to set its value. How do I get a value into it?

Arghhh... I'm going mad with this. Every tutorial I read seems to have some key piece of information missing. Please help!


Kind wishes ~ Patrick


这篇关于DataGrid和ObjectDataSource将值传递给Update但不传递给Delete的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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