Telerik Radgrid GridDataItem.DataItem 更新时为空(OnUpdateCommand 处理程序)
在 RadGrid 上处理 OnUpdateCommand 事件时,DataItem 为 null。
我认为这也代表了行所代表的数据项。
Radgrid 是从 IList 填充的,在处理程序中,代码如下所示...
protected void rgAllocatedClients_UpdateCommand(object sender, GridCommandEventArgs e)
{
if (e.Item is GridDataItem)
{
var gridDataItem = e.Item as GridDataItem;
var client= gridDataItem .DataItem as Client;
....
....
这在处理 ItemDataBound 事件时有效,但在处理 UpdateCommand 事件时无效。我真的需要这个,因为在我的 Client 类中是我想要处理更新的行的 Id。
谢谢,
When handling the OnUpdateCommand event on a RadGrid the DataItem is null.
I thought that this would also represent the data item being represented by the row.
The Radgrid is populated from an IList and in the handler the code looks like this...
protected void rgAllocatedClients_UpdateCommand(object sender, GridCommandEventArgs e)
{
if (e.Item is GridDataItem)
{
var gridDataItem = e.Item as GridDataItem;
var client= gridDataItem .DataItem as Client;
....
....
This works find when handling the ItemDataBound event but not when handling the UpdateCommand event. I really need this as in my Client class is the Id of the row I want to handle the update for.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您的网格在更新命令之前处于编辑模式,您应该将 e.Item 转换为 GridEditableItem 而不是 GridDataItem
Assuming your Grid is in Edit mode befor ethe Update Command, you should cast e.Item to GridEditableItem instead of GridDataItem
使用 GridEditableItem 尝试此操作
Try this by using GridEditableItem