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

Unable to see new values with InPlace editing

1 Answer 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 05 Jul 2012, 03:19 PM
I have a RadGrid that I'm supplying a data source in code-behind, and trying to use InPlace editing.  I'm able to put the row in to the Edit view, enter new values, and click update, but the users new information is never saved:

<telerik:RadGrid ID="radGrdDetails" runat="server"  EnableLinqExpressions="false"
                    AllowPaging="False" AllowSorting="True" GridLines="None" Skin="<%$ AppSettings: YALSkin%>"
                     AllowAutomaticInserts="False" AllowAutomaticUpdates="false" AllowMultiRowEdit="false" showstatusbar="true"  Width="800" AllowFilteringByColumn="true" AutoGenerateColumns="false" AutoGenerateEditColumn="false">
                                                              
                            <MasterTableView CommandItemDisplay="Top"   DataKeyNames="ID" EditMode="InPlace">
                                                               <Columns>
                                    <telerik:GridEditCommandColumn />                                                              
                                    <telerik:GridBoundColumn UniqueName="ID" ReadOnly="true" Visible="false"   DataField="ID"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="NUMBER" ReadOnly="true" DataField="NUMBER" HeaderText="Number" SortExpression="NUMBER"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TYPE" ReadOnly="true" DataField="TYPE" HeaderText="Type" SortExpression="TYPE"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="COUNTY" DataField="COUNTY" HeaderText="County" SortExpression="COUNTY"></telerik:GridBoundColumn>
                                                                   </Columns>                                  
 
 
                                <RowIndicatorColumn>
                                    <HeaderStyle Width="20px" />
                                </RowIndicatorColumn>
                                <ExpandCollapseColumn>
                                    <HeaderStyle Width="20px" />
                                </ExpandCollapseColumn>
                             
                            </MasterTableView>
                         
                </telerik:RadGrid>

the binding is done in Page.Load

I'm trying to build a Hashtabe containing what the user has changed.  Here is the grid's update command:

Protected Sub radGrdDetails_UpdateCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles radGrdDetails.UpdateCommand
       Dim oldValues, newValues, changedValues As Hashtable
       newValues = New Hashtable
       changedValues = New Hashtable
 
       Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
 
       oldValues = editedItem.SavedOldValues
 
       editedItem.ExtractValues(newValues)
 
       For Each key As String In oldValues.Keys
           If oldValues(key) = newValues(key) Then
               'field has not changed, don't edit
           Else
               'field has changed
               changedValues.Add(key, newValues(key))
           End If
       Next
 
   End Sub


However, oldValues and newValues are always exactly the same -- ie, what the user puts in isn't being saved.

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 05 Jul 2012, 05:40 PM
Hello,

Please check below code snippet.

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Bind your grid here
            }
        }

Note : you are not able to get updated value because you grid is rebind before reach to update command event.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or