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

RadGrid Automatic Update issue

7 Answers 276 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Grendizer
Top achievements
Rank 1
Grendizer asked on 18 Sep 2008, 09:56 AM
Hello guys,

I tried to have a look on existing threads and found nothing about the issue I encounter so I apologize in advance if you already have treaten this case.

I have an issue with an automatic update, it seems that data value stored in bound columns marked as readonly are not sent to the update command ... because when the update is performed the read-only field is blanked :(

I don't think this is the normal behavior, right ?!

I did my tests with a Northwind Sql DataSource, using IE7.

Do not hesitate if you need much information.

Hope hear from you soon.

7 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 24 Sep 2008, 08:56 PM
Hi Grendizer,

Can you, please, provide some sample code from the test project or describe how you are updating your database. If you are using automatic functions to extract values from an edited item (e.g. GridTableView's ExtractValuesFromItem() method), please note that columns marked as read-only are not included in the extracted values list.

Regards,
Veli
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Grendizer
Top achievements
Rank 1
answered on 13 Oct 2008, 10:00 AM
Hello Veli,

Sorry for the delay of my response but I was out on vacations :)

Please find sample code that illustrate this issue :

* I'm using classical Northwind SQL DataSource

<asp:SqlDataSource ID="SqlSourceShared" runat="server" ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"   
        DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @original_EmployeeID" 
        InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [Title], [HireDate], [Address]) VALUES (@LastName, @FirstName, @Title, @HireDate, @Address)" 
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [Title], [HireDate], [Address] FROM [Employees]" 
        UpdateCommand="UPDATE [Employees]   
            SET [LastName] = @LastName, [FirstName] = @FirstName, [Title] = @Title, [HireDate] = @HireDate, [Address] = @Address   
            WHERE [EmployeeID] = @original_EmployeeID"> 
        <DeleteParameters> 
            <asp:Parameter Name="original_EmployeeID" Type="Int32" /> 
        </DeleteParameters> 
        <UpdateParameters> 
            <asp:Parameter Name="LastName" Type="String" /> 
            <asp:Parameter Name="FirstName" Type="String" /> 
            <asp:Parameter Name="Title" Type="String" /> 
            <asp:Parameter Name="HireDate" Type="DateTime" /> 
            <asp:Parameter Name="Address" Type="String" /> 
            <asp:Parameter Name="original_EmployeeID" Type="Int32" /> 
            <asp:Parameter Name="original_LastName" Type="String" /> 
            <asp:Parameter Name="original_FirstName" Type="String" /> 
            <asp:Parameter Name="original_Title" Type="String" /> 
            <asp:Parameter Name="original_HireDate" Type="DateTime" /> 
            <asp:Parameter Name="original_Address" Type="String" /> 
        </UpdateParameters> 
        <InsertParameters> 
            <asp:Parameter Name="LastName" Type="String" /> 
            <asp:Parameter Name="FirstName" Type="String" /> 
            <asp:Parameter Name="Title" Type="String" /> 
            <asp:Parameter Name="HireDate" Type="DateTime" /> 
            <asp:Parameter Name="Address" Type="String" /> 
        </InsertParameters>                  
    </asp:SqlDataSource> 


* With pretty simple grid :

<telerik:RadGrid ID="gI" runat="server" EnableViewState="true"   
    AutoGenerateColumns="False" 
    GridLines="None"   
    AllowPaging="True"   
    PageSize="3"   
    ShowStatusBar="false"   
    AllowAutomaticUpdates="true" 
    AllowAutomaticDeletes="true"   
    AllowAutomaticInserts="true"   
    AllowSorting="true" 
    DataSourceID="SqlSourceShared" 
    >  
    <MasterTableView CommandItemDisplay="Top" 
        DataKeyNames="EmployeeID" 
        AutoGenerateColumns="false"   
        EditMode="InPlace">  
        <Columns>  
            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" />  
            <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" UniqueName="LastName" />  
            <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" UniqueName="FirstName" />  
            <telerik:GridBoundColumn DataField="Title" HeaderText="Title" ReadOnly="true" />  
            <telerik:GridBoundColumn Display="false" DataField="HireDate" DataType="System.DateTime" 
                HeaderText="Hire Date" DataFormatString="{0:d}" />  
            <telerik:GridBoundColumn DataField="Address" HeaderText="Address" Display="false" />  
        </Columns>  
    </MasterTableView>  
    <ClientSettings   
        AllowColumnsReorder="false"   
        EnableRowHoverStyle="true"   
        AllowKeyboardNavigation="false"   
        EnablePostBackOnRowClick="false">  
            <Resizing AllowColumnResize="true" EnableRealTimeResize="false" />  
            <Selecting AllowRowSelect="true" />              
    </ClientSettings>  
    <StatusBarSettings LoadingText="Loading ..." ReadyText="Ready" />  
</telerik:RadGrid>  

Note the Title Column that use Title dataFiled with ReadOnly attribute.

If you try to edit & update one row, you'll notice the Title column will be blanked.

So if I understand well the fact that the ExtractValuesFromItem method does not extract read-only field, then here the issue is coming from my data source update statement that use Title field that will not be provided ?!

Could you confirm me this point or let me kow if this is really an issue from the grid.

Note that I have also tested this behavior with the last component release.

Thanks in advance for your time.



0
Accepted
Daniel
Telerik team
answered on 15 Oct 2008, 01:58 PM
Hello Grendizer,

Could you please try the following modification:
<telerik:GridBoundColumn DataField="Title" HeaderText="Title"
ReadOnly="true" ForceExtractValue="Always" /> 

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Grendizer
Top achievements
Rank 1
answered on 20 Oct 2008, 07:26 AM
Hello Daniel,

The ForceExtractValue property solved the issue.

Many thanks for your time & support.

Have a great day.
0
Darren
Top achievements
Rank 1
answered on 10 Jan 2009, 12:51 AM

  Thanks I was having the same issue and ForceExtractValue resolved this issue for Update, but Delete is still having a problem.  The value for LocationMasterId is 0 for Delete, rather than the value for the row.  How can this be resolved for Delete?

Thanks

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LocationMaster.ascx.cs" Inherits="IdentityInfo.LocationMaster" %> 
 
 
<%@ Register Assembly="RadInput.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %> 
 
<%@ Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %> 
 
<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %> 
 
&nbsp;&nbsp;&nbsp;<br /> 
    &nbsp;  
    <rad:RadGrid ID="LocationMasterGrid" runat="server" AllowPaging="True"   
    AllowSorting="True" GridLines="None"   
    EnableAJAX="True" PageSize="30" AllowFilteringByColumn="True"   
    Width="100%" DataSourceID="LocationMasterDataSource"   
    AutoGenerateColumns="False" 
    AllowAutomaticDeletes="True" AllowAutomaticInserts="True"   
    AllowAutomaticUpdates="True">  
        <MasterTableView  CommandItemDisplay="Top"   
            PageSize="20" datasourceid="LocationMasterDataSource">  
            <ExpandCollapseColumn Resizable="False" Visible="False">  
                <HeaderStyle Width="20px" /> 
            </ExpandCollapseColumn> 
            <RowIndicatorColumn Visible="False">  
                <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
              
                        <Columns> 
              
                     <rad:GridEditCommandColumn> 
                </rad:GridEditCommandColumn> 
               <rad:GridBoundColumn DataField="LocationMasterId" ReadOnly="true" ForceExtractValue="Always"  DataType="System.Int32" HeaderText="Location Master ID" SortExpression="LocationMasterId" 
                    UniqueName="LocationMasterId">  
                </rad:GridBoundColumn> 
               <rad:GridBoundColumn DataField="FacilityDisplayName" HeaderText="Facility Display Name" SortExpression="FacilityDisplayName" 
                    UniqueName="FacilityDisplayName">  
                </rad:GridBoundColumn> 
                  <rad:GridBoundColumn DataField="OL_FacilityName" HeaderText="OL Facility Name" SortExpression="OL_FacilityName" 
                    UniqueName="OL_FacilityName">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="OL_FacilityCode" HeaderText="OL Facility Code" SortExpression="OL_FacilityCode" 
                    UniqueName="OL_FacilityCode">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="OL_LocationCode" HeaderText="OL Location Code" SortExpression="OL_LocationCode" 
                    UniqueName="OL_LocationCode">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="PS_LocationCode" HeaderText="PS Location Code" SortExpression="PS_LocationCode" 
                    UniqueName="PS_LocationCode">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="PS_LocationDescription" HeaderText="PS Location Description" SortExpression="PS_LocationDescription" 
                    UniqueName="PS_LocationDescription">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationPhone" HeaderText="Phone" SortExpression="LocationPhone" 
                    UniqueName="LocationPhone">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationPhoneExt" HeaderText="Phone Ext" SortExpression="LocationPhoneExt" 
                    UniqueName="LocationPhoneExt">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationFax" HeaderText="Fax" SortExpression="LocationFax" 
                    UniqueName="LocationFax">  
                </rad:GridBoundColumn> 
                  <rad:GridBoundColumn DataField="LocationAddress1" HeaderText="Address 1" SortExpression="LocationAddress1" 
                    UniqueName="LocationAddress1">  
                </rad:GridBoundColumn> 
                  <rad:GridBoundColumn DataField="LocationAddress2" HeaderText="Address 2" SortExpression="LocationAddress2" 
                    UniqueName="LocationAddress2">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationAddress3" HeaderText="Address 3" SortExpression="LocationAddress3" 
                    UniqueName="LocationAddress3">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationAddress4" HeaderText="Address 4" SortExpression="LocationAddress4" 
                    UniqueName="LocationAddress4">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationCity" HeaderText="City" SortExpression="LocationCity" 
                    UniqueName="LocationCity">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationState" HeaderText="State" SortExpression="LocationState" 
                    UniqueName="LocationState">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationPostalCode" HeaderText="Postal Code" SortExpression="LocationPostalCode" 
                    UniqueName="LocationPostalCode">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationCountry" HeaderText="Country" SortExpression="LocationCountry" 
                    UniqueName="LocationCountry">  
                </rad:GridBoundColumn> 
                     <rad:GridBoundColumn DataField="LocationCountryCode" HeaderText="Country Code" SortExpression="LocationCountryCode" 
                    UniqueName="LocationCountryCode">  
                </rad:GridBoundColumn> 
                            
                             
                            <rad:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column">  
                            </rad:GridButtonColumn> 
                            
                             
                  </Columns> 
              
 
          
<%--<EditFormSettings> 
<EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
</EditFormSettings>--%><EditFormSettings>  
<EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
</EditFormSettings> 
        </MasterTableView> 
        <PagerStyle Mode="NextPrevAndNumeric" Position="TopAndBottom" /> 
    </rad:RadGrid><br /> 
   
<asp:ObjectDataSource ID="LocationMasterDataSource" runat="server"   
    SelectMethod="GetLocationMasterData"   
    TypeName="IdentityInfo.miisidentitydata.IdentityInformation"   
    UpdateMethod="UpdateLocationMasterData"   
    DeleteMethod="DeleteLocationMasterData" InsertMethod="InsertLocationMasterData"   
    onupdating="LocationMasterDataSource_Updating">  
    <DeleteParameters> 
        <asp:Parameter Name="LocationMasterId" Type="Int32" /> 
    </DeleteParameters> 
    <UpdateParameters> 
        <asp:Parameter Name="LocationMasterId" Type="Int32" /> 
        <asp:Parameter Name="FacilityDisplayName" Type="String" /> 
        <asp:Parameter Name="OL_FacilityName" Type="String" /> 
        <asp:Parameter Name="OL_FacilityCode" Type="String" /> 
        <asp:Parameter Name="OL_LocationCode" Type="String" /> 
        <asp:Parameter Name="PS_LocationCode" Type="String" /> 
        <asp:Parameter Name="PS_LocationDescription" Type="String" /> 
        <asp:Parameter Name="LocationPhone" Type="String" /> 
        <asp:Parameter Name="LocationPhoneExt" Type="String" /> 
        <asp:Parameter Name="LocationFax" Type="String" /> 
        <asp:Parameter Name="LocationAddress1" Type="String" /> 
        <asp:Parameter Name="LocationAddress2" Type="String" /> 
        <asp:Parameter Name="LocationAddress3" Type="String" /> 
        <asp:Parameter Name="LocationAddress4" Type="String" /> 
        <asp:Parameter Name="LocationCity" Type="String" /> 
        <asp:Parameter Name="LocationState" Type="String" /> 
        <asp:Parameter Name="LocationPostalCode" Type="String" /> 
        <asp:Parameter Name="LocationCountry" Type="String" /> 
        <asp:Parameter Name="LocationCountryCode" Type="String" /> 
    </UpdateParameters> 
    <InsertParameters> 
        <asp:Parameter Name="FacilityDisplayName" Type="String" /> 
        <asp:Parameter Name="OL_FacilityName" Type="String" /> 
        <asp:Parameter Name="OL_FacilityCode" Type="String" /> 
        <asp:Parameter Name="OL_LocationCode" Type="String" /> 
        <asp:Parameter Name="PS_LocationCode" Type="String" /> 
        <asp:Parameter Name="PS_LocationDescription" Type="String" /> 
        <asp:Parameter Name="LocationPhone" Type="String" /> 
        <asp:Parameter Name="LocationPhoneExt" Type="String" /> 
        <asp:Parameter Name="LocationFax" Type="String" /> 
        <asp:Parameter Name="LocationAddress1" Type="String" /> 
        <asp:Parameter Name="LocationAddress2" Type="String" /> 
        <asp:Parameter Name="LocationAddress3" Type="String" /> 
        <asp:Parameter Name="LocationAddress4" Type="String" /> 
        <asp:Parameter Name="LocationCity" Type="String" /> 
        <asp:Parameter Name="LocationState" Type="String" /> 
        <asp:Parameter Name="LocationPostalCode" Type="String" /> 
        <asp:Parameter Name="LocationCountry" Type="String" /> 
        <asp:Parameter Name="LocationCountryCode" Type="String" /> 
    </InsertParameters> 
</asp:ObjectDataSource> 
 
 

 

0
Sebastian
Telerik team
answered on 10 Jan 2009, 07:35 AM
Hello Darren,

The ForceExtractValue property is meaningful for read-only fields with values that should be fetched on update/insert operation. When deleting items and using automatic deletes with delete parameters for the data source control, you need to add the respective field (LocationMasterId in your case) to the DataKeyNames collection of the MasterTableView.

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Darren
Top achievements
Rank 1
answered on 13 Jan 2009, 01:13 AM

  Thanks Sebastian-  that did it.
Tags
Grid
Asked by
Grendizer
Top achievements
Rank 1
Answers by
Veli
Telerik team
Grendizer
Top achievements
Rank 1
Daniel
Telerik team
Darren
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or