Telerik Radgrid GridDataItem.DataItem 更新时为空(OnUpdateCommand 处理程序)

发布于 2024-08-31 19:13:20 字数 523 浏览 6 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

以可爱出名 2024-09-07 19:13:22

假设您的网格在更新命令之前处于编辑模式,您应该将 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

昨迟人 2024-09-07 19:13:22

使用 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
}

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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文