无法在Telerik RadGrid BatchEdit模式下获取每个单元格值

时间:2018-04-15 08:08:17

标签: c# asp.net telerik radgrid

我有Telerik RadGrid和BatchEditMode,

我的要求是按钮点击获取单元格的所有值(在批量编辑模式下输入),但我无法获得这些值。 我的主要目标是将整个RadGrid作为数据表传递给数据库过程。 这是我的Telerik RadGrid代码。

enter code here
     <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" 
            CellSpacing="0" GridLines="Both"
            OnItemDataBound="RadGrid1_ItemDataBound" AllowPaging="false"
            AutoGenerateColumns="false" 
            onneeddatasource="RadGrid1_NeedDataSource"
            >
            <ClientSettings AllowKeyboardNavigation="true">
                <Selecting AllowRowSelect="True" CellSelectionMode="MultiColumn" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                <Resizing AllowColumnResize="true" AllowResizeToFit="true" />

                <ClientEvents OnBatchEditGetCellValue="BatchEditGetCellValue"   OnCellSelected="cellSelected"  OnRowCreated="RowCreated" 
                    OnBatchEditOpening="BatchEditOpening"
                     />
            </ClientSettings>

            <MasterTableView CommandItemDisplay="Bottom" Width="100%" HeaderStyle-HorizontalAlign="Center"
                FilterItemStyle-HorizontalAlign="Center" DataKeyNames="COLUMN1"
                HorizontalAlign="Justify" EditMode="Batch" AutoGenerateColumns="false">

                <BatchEditingSettings EditType="Cell" SaveAllHierarchyLevels="true"  />

            </SortExpressions>--%>

                <Columns>




                    <telerik:GridBoundColumn DataField="CFIT_ID" HeaderText="Cashflow" SortExpression="ProductName"
                        UniqueName="CFIT_ID" Display="false">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">
                            </RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>



                     <telerik:GridNumericColumn DataField="COLUMN1" HeaderStyle-Width="83px" HeaderText="COLUMN1" 
                        SortExpression="COLUMN1" UniqueName="COLUMN1">
                    </telerik:GridNumericColumn>






                </Columns>

            </MasterTableView>

        </telerik:RadGrid>
        <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click"  Text="Submit"/>

    ////////////////////////////////////////////////////////////////

尝试使用此代码获取每个数字单元格值。

foreach(RadGrid1.Items中的GridEditableItem项)             {                 dr = dt.NewRow();

            RadNumericTextBox DNumericTextBox = (RadGrid1.MasterTableView.GetBatchColumnEditor("COLUMN1") as GridNumericColumnEditor).NumericTextBox;
            dr["COLUMN1"] = item["COLUMN1"].Text.ToString();
            dt.Rows.Add(dr);
        }

1 个答案:

答案 0 :(得分:0)

请先试用此链接进行演示并了解Grid - Batch Editing

我正在使用public class MyViewModel : BindableBase { private ParentObject _parent; public ParentObject Parent { get { return _parent; } set { _parent = value; RaisePropertyChanged(nameof(Parent); // SomeMethod(Parent); } } public void SomeMethod(ParentObject obj) { ... } } public class ParentObject : BindableBase { private int _child; public int Child { get { return _child; } set { _child = value; RaisePropertyChanged(nameof(Child); } } } 。以下是BatchEditing的代码。

BatchEditingSettings EditType="Row"