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

Update not updating

2 Answers 273 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TSCGlobal
Top achievements
Rank 1
TSCGlobal asked on 03 Dec 2010, 05:50 PM

Okay, so I have a RadGrid that is being filled with data.  I have an edit column.  I click the edit column, change a record, and hit update.  It posts back to the page, and goes back to the radgrid, only the update didn't happen. 

1. My first assumption was that I forgot to set it up so that radgrid would refresh, so I check the data table in the SQL database, only to find that the update simply didn't happen, so...

2. I check the ObjectDataSource; yup, all parameters exist.

3. I check the SQL to make sure the update is correct.  Yup, the update is correct.

So in essence, all my code is correct, it's Radgrid that is not working.  The question is, why?  If anyone has a clue, please let me know.  It's probably something that tired eyes are merely overlooking.  I think I lost a little more of my hair over this one...lol. 

...so here's the relevant .aspx code;

<telerik:RadGrid ID="RecentReviewsGrid" runat="server" 
    AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True" 
    AutoGenerateColumns="False" DataSourceID="dsTransactionReview" GridLines="None" 
    HorizontalAlign="Center" PageSize="20">
    <mastertableview datakeynames="TransactionID" 
    datasourceid="dsTransactionReview" headerstyle-horizontalalign="Center">
        <commanditemsettings exporttopdftext="Export to Pdf" />
        <rowindicatorcolumn>
            <HeaderStyle Width="20px" />
        </rowindicatorcolumn>
        <expandcollapsecolumn>
            <HeaderStyle Width="20px" />
        </expandcollapsecolumn>
        <Columns>
            <telerik:GridBoundColumn 
                DataField="TransactionID" 
                DataType="System.Int32" 
                HeaderText="TransactionID" 
                ReadOnly="True" 
                SortExpression="TransactionID" 
                UniqueName="TransactionID" 
                Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn 
                DataField="OrderID" 
                DataType="System.Int32" 
                HeaderText="OrderID" 
                SortExpression="OrderID" 
                UniqueName="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn 
                DataField="OrderDate" 
                DataType="System.DateTime" 
                HeaderText="OrderDate" 
                SortExpression="OrderDate" 
                UniqueName="OrderDate" 
                Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn 
                DataField="CreatedBy" 
                HeaderText="CreatedBy" 
                SortExpression="CreatedBy" 
                UniqueName="CreatedBy">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn 
                DataField="CategoryType" 
                HeaderText="CategoryType" 
                SortExpression="CategoryType" 
                UniqueName="CategoryType">
            </telerik:GridBoundColumn>
            <telerik:GridCheckBoxColumn 
                DataField="IsEntryCorrect" 
                DataType="System.Boolean" 
                HeaderStyle-Width="50px" 
                HeaderText="Correct Code?" 
                ItemStyle-Width="50px" 
                SortExpression="IsEntryCorrect" 
                UniqueName="IsEntryCorrect">
                <HeaderStyle Width="50px" />
                <ItemStyle Width="50px" />
            </telerik:GridCheckBoxColumn>
            <telerik:GridCheckBoxColumn 
                DataField="Suitable" 
                DataType="System.Boolean" 
                HeaderStyle-Width="50px" 
                HeaderText="Suitable?" 
                ItemStyle-Width="50px" 
                SortExpression="Suitable" 
                UniqueName="Suitable">
                <HeaderStyle Width="50px" />
                <ItemStyle Width="50px" />
            </telerik:GridCheckBoxColumn>
            <telerik:GridBoundColumn 
                DataField="CorrectCode" 
                HeaderText="Correct Code" 
                SortExpression="CorrectCode" 
                UniqueName="CorrectCode">
            </telerik:GridBoundColumn>
            <telerik:GridCheckBoxColumn 
                DataField="NeedCoached" 
                DataType="System.Boolean" 
                HeaderStyle-Width="50px" 
                HeaderText="Need Coached?" 
                ItemStyle-Width="50px" 
                SortExpression="NeedCoached" 
                UniqueName="NeedCoached">
                <HeaderStyle Width="50px" />
                <ItemStyle Width="50px" />
            </telerik:GridCheckBoxColumn>
            <telerik:GridBoundColumn 
                DataField="Comments" 
                HeaderText="Comments" 
                SortExpression="Comments" 
                UniqueName="Comments">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn 
                DataField="DateReviewed" 
                DataType="System.DateTime" 
                HeaderText="Review Date" 
                SortExpression="DateReviewed" 
                UniqueName="DateReviewed">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn 
                DataField="Reviewer" 
                HeaderText="Reviewer" 
                SortExpression="Reviewer" 
                UniqueName="Reviewer">
            </telerik:GridBoundColumn>
            <telerik:GridEditCommandColumn UniqueName="EditCommand">
            </telerik:GridEditCommandColumn>
        </Columns>
        <HeaderStyle HorizontalAlign="Center" />
    </mastertableview>
</telerik:RadGrid>
  
<asp:ObjectDataSource ID="dsTransactionReview" runat="server" 
    DeleteMethod="Delete" 
    OldValuesParameterFormatString="{0}" 
    SelectMethod="GetData" 
    TypeName="Pan_App.PanDataTableAdapters.Tink_CoachingTableAdapter" 
    UpdateMethod="Update">
    <DeleteParameters>
        <asp:Parameter Name="TransactionID" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="OrderID" Type="Int32" />
        <asp:Parameter Name="OrderDate" Type="DateTime" />
        <asp:Parameter Name="CreatedBy" Type="String" />                        
        <asp:Parameter Name="CategoryType" Type="String" />
        <asp:Parameter Name="IsEntryCorrect" Type="Boolean" />
        <asp:Parameter Name="Suitable" Type="Boolean" />
        <asp:Parameter Name="CorrectCode" Type="String" />
        <asp:Parameter Name="NeedCoached" Type="Boolean" />
        <asp:Parameter Name="Comments" Type="String" />
        <asp:Parameter Name="DateReviewed" Type="DateTime" />                            
        <asp:Parameter Name="Reviewer" Type="String" />
        <asp:Parameter Name="TransactionID" Type="Int32" />
    </UpdateParameters>
</asp:ObjectDataSource>

I think that about covers it.  Here's the Update command for SQL:
UPDATE    TableName
SET              
    OrderID = @OrderID, 
    OrderDate = @OrderDate, 
    CreatedBy = @CreatedBy, 
    CategoryType = @CategoryType, 
    IsEntryCorrect = @IsEntryCorrect, 
    Suitable = @Suitable, 
    CorrectCode = @CorrectCode, 
    NeedCoached = @NeedCoached, 
    Comments = @Comments, 
    DateReviewed = @DateReviewed, 
    Reviewer = @Reviewer
WHERE     (TransactionID = @TransactionID)
seems straight-forward enough...any clue would be appreciated.

2 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 09 Dec 2010, 08:54 AM
Hello beemer,

1. With regards to your first question, if you need to put a given item into EditMode, you should be accomplishing this in the OnPreRender event in the way you are trying to. Instead, you can use the EditIndexes collection of RadGrid as described in the following help topic:
http://www.telerik.com/help/aspnet-ajax/grdputallitemsineditmodenoadditionalrebind.html

Furthermore, do make sure that you are using Advanced databinding as opposed to Simple databinding.

2. Concerning the second issue, take a look at the following online example and note how the binding expressions are set for the controls in the edit form:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx
 
In addition, do notice how the DataItem property is exposed in the code-behind for the user control.

Hope it helps.

Best wishes,
Tsvetoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Accepted
Tsvetoslav
Telerik team
answered on 09 Dec 2010, 08:57 AM
Hi beemer,

Please, disregard my previous post - it was meant for another customer.

Regarding the issue you have encountered I suspect the cause for it is due to your using  Simple databinding as opposed to Advanced databinding for the grid control. Please, make sure that you have implemented the latter approach.

All the best,
Tsvetoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
TSCGlobal
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or