Telerik Radgrid GridDataItem.DataItem在更新时为空(OnUpdateCommand处理程序) [英] Telerik Radgrid GridDataItem.DataItem is empty when updating (OnUpdateCommand handler)

查看:56
本文介绍了Telerik Radgrid GridDataItem.DataItem在更新时为空(OnUpdateCommand处理程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在RadGrid上处理OnUpdateCommand事件时,DataItem为null.

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.

Radgrid由IList填充,并且在处理程序中,代码如下所示.

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;
        ....
        ....

在处理ItemDataBound事件时有效,但在处理UpdateCommand事件时找不到.我真的需要这个,因为在我的Client类中,是我要为其处理更新的行的ID.

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.

谢谢

推荐答案

尝试使用GridEditableItem

Try this by using GridEditableItem


 protected void grdContacts_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {

        string idEditing = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString();
        GridEditableItem editedItem = e.Item as GridEditableItem;
        Hashtable newValues = new Hashtable();
// ur code
}

这篇关于Telerik Radgrid GridDataItem.DataItem在更新时为空(OnUpdateCommand处理程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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