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

Problem with updating grid rating

5 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
C O
Top achievements
Rank 1
C O asked on 13 May 2010, 08:13 PM
The code is basicly from the demo example, however, update results in error: ...object reference not set to an instance of an object. any help is appreciated.

VB:
If e.CommandName = "UpdateRating" Then  
                Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)  
                Dim values As New Hashtable()  
                item.ExtractValues(values)  
                values("ChangeRequestID") = item.GetDataKeyValue("ChangeRequestID")  
                values("Completed") = Int16.Parse(values("Completed"))  
                values("Accepted") = Int16.Parse(values("Accepted"))  
                values("Reviewed") = Int16.Parse(values("Reviewed"))  
                  
                For Each entry As DictionaryEntry In values  
                    SqlDataSource1.UpdateParameters(entry.Key.ToString()).DefaultValue = entry.Value.ToString()  
                Next  
                SqlDataSource1.Update()  
            End If 

And the grid:
<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="True" 
              AllowAutomaticInserts="True" AllowAutomaticUpdates="True" OnItemCommand="RadGrid1_ItemCommand" Height="900px" PageSize="25" Skin="Black" DataSourceID="SqlDataSource1">  
            <PagerStyle Mode="Slider" /> 
 
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="ChangeRequestID" AllowMultiColumnSorting="True" DataSourceID="SqlDataSource1" AllowFilteringByColumn="True">  
                <Columns> 
                    <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="Images/Update.gif" CommandName="UpdateRating" UniqueName="UpdateColumn" HeaderText="Update" /> 
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="Images/Edit.gif" HeaderText="Edit" /> 
                    <telerik:GridRatingColumn DataField="Accepted" UniqueName="Accepted" Precision="Item" ReadOnly="False" ItemCount="1" HeaderText="Accepted" AllowRatingInViewMode="true" /> 
                    <telerik:GridRatingColumn Datafield="Reviewed" UniqueName="Reviewed" Precision="Item" ReadOnly="False" ItemCount="1" HeaderText="Reviewed" AllowRatingInViewMode="true" /> 
                    <telerik:GridRatingColumn Datafield="Completed" UniqueName="Completed" Precision="Item" ReadOnly="False" ItemCount="1" HeaderText="Completed" AllowRatingInViewMode="true" /> 
                    <telerik:GridRatingColumn Datafield="Priority" UniqueName="Priority" Precision="Item" ReadOnly="false" ItemCount="5" HeaderText="Priority" AllowRatingInViewMode="false" /> 
                    <telerik:GridBoundColumn DataField="ChangeRequestID" UniqueName="ChangeRequestID" HeaderText="ID" Visible="false" /> 
                </Columns> 
                <EditFormSettings EditFormType="Template">  
                <EditColumn UniqueName="EditCommandColumn1" /> 
                    <FormTemplate> 
.... 

And the datasource:
<asp:SqlDataSource ID="SqlDataSource1" DataSourceMode="DataSet" runat="server" ConnectionString="<%$ ConnectionStrings:hldbConnectionString %>" 
             
              InsertCommand="INSERT INTO ChangeRequestTracker(Accepted, Completed, Reviewed, Priority) VALUES (0, 0, 0, @Priority)"   
                                          
              SelectCommand="SELECT * FROM ChangeRequestTracker ORDER BY ChangeRequestID DESC" 
                 
              UpdateCommand="UPDATE ChangeRequestTracker SET Priority=@Priority, Accepted=@Accepted, Reviewed=@Reviewed, Completed=@Completed  WHERE ChangeRequestID = @ChangeRequestID">  
              <UpdateParameters> 
                  <asp:Parameter Name="ChangeRequestID"/>  
                  <asp:Parameter Name="Priority"/>  
                  <asp:Parameter Name="Accepted"/>  
                  <asp:Parameter Name="Reviewed"/>  
                  <asp:Parameter Name="Completed"/>  
              </UpdateParameters> 
              <InsertParameters> 
                  <asp:Parameter Name="Priority"/>  
                  <asp:Parameter Name="Accepted"/>  
                  <asp:Parameter Name="Reviewed"/>  
                  <asp:Parameter Name="Completed"/>  
              </InsertParameters> 
          </asp:SqlDataSource> 

5 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 14 May 2010, 02:20 PM
Hello C O,

Could you please specify on which line of the code is the mentioned error thrown?

All the best,
Iana
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
C O
Top achievements
Rank 1
answered on 14 May 2010, 03:57 PM
hi, The error is on line 6.  thanks.
0
Iana Tsolova
Telerik team
answered on 17 May 2010, 11:17 AM
Hello C O,

From the provided information I assume that for some reason the "Completed" new value is not extracted. Does the error occur when the grid item is in edit mode or does it persist if auto-generated edit forms are used instead of templated?

Sincerely yours,
Iana
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
C O
Top achievements
Rank 1
answered on 17 May 2010, 03:03 PM
I modified the grid to use auto generated forms and the same error appears for Insert, Update, and the rating update. 
0
Iana Tsolova
Telerik team
answered on 17 May 2010, 03:50 PM
Hello C O,

Could you please open a formal support ticket and send us a runnable sample there? We will debug it locally to find a proper resolution for your case.

Looking forward your reply,
Iana
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
C O
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
C O
Top achievements
Rank 1
Share this question
or