This is a migrated thread and some comments may be shown as answers.

Need help with RadGrid

3 Answers 72 Views
Documentation and Tutorials
This is a migrated thread and some comments may be shown as answers.
Tim Inouye
Top achievements
Rank 1
Tim Inouye asked on 21 May 2015, 11:21 PM

Hi,

 I'm new to the RadGird control and am trying to use the Batch editing capability.

 I am populating the control from code and have set the OnBatchEditCommand on the form.

When I view the form and add items using the Add New Item prompt I am able to create new items.  However, when I Click Save Changes my BatchEditCommand event  is fired, but the command collection count is zero.

I have included a screen shot and snippets of code:

    <form id="frmList" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <div>
    <telerik:RadGrid ID="grdList" OnBatchEditCommand="grdList_BatchEditCommand" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False" runat="server">
     <MasterTableView  EditMode="Batch" CommandItemDisplay="Top" DataKeyNames="Code" Name="SalesCodes"> 
        <BatchEditingSettings OpenEditingEvent="Click" EditType="Cell" />
     </MasterTableView>
    </telerik:RadGrid>
    </div>
    </form>

 _________________________________________________________________________________

                             colText = New GridBoundColumn
                            colText.HeaderText = rsData.Item("FieldCaption")
                            colText.DataField = rsData.Item("FieldName")
                            colText.MaxLength = rsData.Item("FieldLength")
                            iFormWidth = iFormWidth + rsData.Item("FieldWidth") + 3
                            If Not IsDBNull(rsData.Item("FieldDefault")) Then
                                structDefaultValues(iDefaultValues).iCellNumber = rsData.Item("FieldID")
                                structDefaultValues(iDefaultValues).sDefault = rsData.Item("FieldDefault")
                                structDefaultValues(iDefaultValues).sType = rsData.Item("FieldType")
                                iDefaultValues = iDefaultValues + 1
                            End If
                            grdList.MasterTableView.EditFormSettings.CaptionDataField = sKeyField
                            grdList.MasterTableView.Name = strName
                            grdList.MasterTableView.DataKeyNames = arrKeys
                            grdList.Columns.Add(colText)

____________________________________________________________________

    Protected Sub grdList_BatchEditCommand(sender As Object, e As GridBatchEditingEventArgs)
        For Each Cmd As GridBatchEditingCommand In e.Commands
            Dim newval As Hashtable = Cmd.NewValues
        Next
    End Sub

 

3 Answers, 1 is accepted

Sort by
0
Tim Inouye
Top achievements
Rank 1
answered on 22 May 2015, 05:25 PM

After further testing I've found edited rows are passed to the OnBatchEditCommand event, but no added rows are passed.

Can someone help me with this.

0
Viktor Tachev
Telerik team
answered on 26 May 2015, 08:23 AM
Hello Tim,

I examined the code and noticed that the columns in RadGrid are added in the code-behind. Given that RadGrid is declared in the markup I guess that the columns are added in Page_Load.

Note that in this scenario the columns should be added to the GridTableView before their properties are defined. Check out the following article where the approach is illustrated.


Try to modify the code and see if the behavior changes. In case the issue persists, please share the complete markup with the related code-behind. Thus, we will be able to examine the code and look for what could cause the behavior.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tim Inouye
Top achievements
Rank 1
answered on 26 May 2015, 04:58 PM

Thank you VIktor !!

That solved the problem.

Best regards,

Tim Inouye

Tags
Documentation and Tutorials
Asked by
Tim Inouye
Top achievements
Rank 1
Answers by
Tim Inouye
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or