RadGrid

时间:2015-05-21 17:26:46

标签: telerik-grid radgrid itemcommand

我有一个包含MasterTableView和DetailView的RadGrid。我试图在删除DetailView Row时更改MasterTableView中存在的Sub Total的值。我能够在父表中获得控件,并且能够更改该值。然而,价值没有反映出来。我试过多个选项,例如Rebind()方法以及e.Item.OwnerTableView.DataBind()。这是我的ItemCommand函数的样子

    Private Sub dbgView_ItemCommand(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles dbgView.ItemCommand
            If e.CommandName.ToLower.Equals(GlobalConstants.Key_Delete_CommandName) And e.Item.OwnerTableView.Name = "Tax" Then
                   dataItem = DirectCast(e.Item.OwnerTableView.ParentItem, GridDataItem)
                   Dim numSubTotal As NumericBox = dataItem.FindControl("numAmount")
                   numSubTotal.Text = "New Value"
                   ' e.Item.OwnerTableView.DataBind()
            End If

有人可以帮我理解新价值没有反映的原因吗?这是我的网格看起来像

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="dbgView">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="dbgView"></telerik:AjaxUpdatedControl>
                           </telerik:AjaxUpdatedControl>
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadGrid ID="dbgView" runat="server" AutoGenerateColumns="False" AllowPaging="True"
                PageSize="5" GridLines="Horizontal" Skin="Office2010Blue" Style="border: 0 none"
                AllowAutomaticInserts="True">
                <PagerStyle Mode="NumericPages"></PagerStyle>
                <MasterTableView Width="100%" CommandItemDisplay="Top" Name="GLLine" AllowNaturalSort="False"
                    PageSize="10" DataKeyNames="Key" NoDetailRecordsText="No records to display.">
                    <DetailTables> .....

更新 在进一步挖掘时,我知道我需要重新绑定网格帖子,我的操作已执行。然而,当我表演Rebind时,我正在异常

[HttpException(0x80004005):DataBinding:'System.Collections.DictionaryEntry'不包含名为'TaxID'的属性。    System.Web.UI.DataBinder.GetPropertyValue(Object container,String propName)+384    Telerik.Web.UI.GridTableView.PopulateDataKey(Object dataItem,DataKey key,String name)+457    Telerik.Web.UI.GridTableView.PopulateDataKeys(Object dataItem)+241

但是我在正常操作期间没有遇到这个问题。我能够找到所有正常操作的数据密钥。可能出现什么问题?

更新 根据Telerik的以下链接,删除详细信息表行时不会更新主表。

http://www.telerik.com/forums/master-grid-not-rebinding-after-detail-table-delete-command

我正在尝试在本网站中提到的Rebind。但是,如上所述,我正在获得DataKeyValues的异常。任何指针都会有所帮助。

1 个答案:

答案 0 :(得分:0)

问题已经解决!!我有很多链接指示我执行Rebind()操作。然而,这开始创建多个其他问题。这个问题是通过编写一个Javascript方法处理GridButtonColumn的onclick事件来处理的,方法是从DetailView和Master Table View传递字段的控制ID。