RadGrid - 批量编辑中编辑模板中同一列中的多个控件

时间:2016-10-01 12:23:23

标签: asp.net telerik radgrid

我在radgrid中使用批量编辑,网格外有保存按钮。在侧面网格中有模板列,它们的编辑模板有多个值。我可以为它们分配值。但是当我在侧浴编辑命令方法中点击保存时,newvalues的相应键给出[object object]的值

 <telerik:GridTemplateColumn HeaderText="Dwg Sch" ColumnGroupName="WACompOrderEntry" UniqueName="DwgSchedule" HeaderTooltip="This is the date the factory has promised to provide approval drawings to the field (loaded automatically from Vista when available)">
                        <ItemTemplate>
                            <asp:Label runat="server" ID="lblRdDwgSch" Text='<%# Eval("Vista_Sub", "{0:M/d/yy}") %>' ToolTip="This is the date the factory has promised to provide approval drawings to the field (loaded automatically from Vista when available)"></asp:Label>
                            <br />
                            <asp:Label ID="lblDwgSch" runat="server"></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadDatePicker ID="rdDwgSch" runat="server" Width="80px" DbSelectedDate='<%# Eval("Vista_Sub", "{0:M/d/yy}") %>' ToolTip="This is the date the factory has promised to provide approval drawings to the field (loaded automatically from Vista when available)"></telerik:RadDatePicker>
                            <asp:TextBox ID="txtDwgSch" runat="server" Width="80px" />
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>

以上是模板列定义

   protected void gridMilestoneMatrixEntry_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
        {
            if (e.Commands == null)
            {
                return;
            }
            Cache.Remove("MileStoneData");
            var updatedCommands = e.Commands.Where(x => x.Type == GridBatchEditingCommandType.Update);
            var deletedCommands = e.Commands.Where(x => x.Type == GridBatchEditingCommandType.Delete);
            List<int> updatedRecords = new List<int>();
            List<long> deletedRecords = new List<long>();
            if (updatedCommands != null && updatedCommands.Count() > 0)
            {
                updatedRecords = UpdateMilestoneMatrix(updatedCommands.ToList());
            }

现在哈希表中的键值不会给对象赋值 updatedValues [&#34; DwgSchedule&#34;]它给出了[对象对象]的价值

 if (updatedValues["DwgSchedule"] != null)
                {
                    tempStr = updatedValues["DwgSchedule"].ToString();
                    if (!string.IsNullOrEmpty(tempStr))
                    {
                        confDwgExp = DateTime.ParseExact(updatedValues["DwgSchedule"].ToString(), "M/d/yyyy", CultureInfo.InvariantCulture);
                    }
                    tempStr = string.Empty;
                }

1 个答案:

答案 0 :(得分:1)

我决定做这些事情的方法是使用<div ng-Controller="ctrl" ng-bind="data.admin" ></div> 遍历网格的行。 这允许您访问每个单独的行,这实际上允许您访问行的各个控件(即不仅是单元格,而是行上的所有内容)。

RadGrid.Items

如果您想要c#版本,只需使用telerik's converter

进行转换即可

编辑:

Private Sub RbtnSaveAll_Click(sender As Object, e As EventArgs) Handles RbtnSaveAll.Click

    For Each item As GridDataItem In grdActivities.Items 'Iterates over the rows
    'Get your controls by using item.findcontrol("controlname").
    'Then send the data of the changed controls to the datasource
    Next

    bindGrid(True) 'Do your bind event if necessary
End Sub

VB-代码:

<asp:Button ID="btnBulkBookOn" runat="server" Text="Book On" CommandName="Update"/>
相关问题