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

Rate not updating

1 Answer 64 Views
Rating
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 2
Allan asked on 20 Jul 2011, 07:34 PM
I have a Rating control in a FormView which is populated using a SQLDataSource.

<asp:FormView ID="FormView2" runat="server" DataKeyNames="IDProjectsMaster" 
    DataSourceID="sds_MasterProjects">
                                    <EditItemTemplate>
                                        <table cellpadding="3" cellspacing="0" style="width: 100%">
                                            <tr>
                                                <td class="tbltd" style="width: 110px">
                                                    Project Subject:</td>
                                                <td>
                                                    <asp:TextBox ID="SubjectTextBox" runat="server" 
                                                        Text='<%# Bind("Subject") %>' Width="400px" />
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                        ControlToValidate="SubjectTextBox" ErrorMessage="*" Font-Bold="True" 
                                                        Font-Size="Medium" ForeColor="#FF3300"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 110px">
                                                    Enter Date:</td>
                                                <td>
                                                    <asp:Label ID="EnterDateLabel" runat="server" 
                                                        Text='<%# Bind("EnterDate","{0:d}") %>' />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 110px">
                                                    Completion Date:</td>
                                                <td>
                                                    <telerik:RadDatePicker ID="RadDatePicker2" Runat="server" 
                                                        Culture="English (United States)" DbSelectedDate='<%# Bind("ResolutionDate") %>'>
                                                        <Calendar ID="Calendar2" Runat="server" UseColumnHeadersAsSelectors="False" 
                                                            UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                                        </Calendar>
                                                        <DatePopupButton HoverImageUrl="" ImageUrl="" />
                                                        <DateInput ID="DateInput2" Runat="server" DateFormat="M/d/yyyy" DisplayDateFormat="M/d/yyyy">
                                                        </DateInput>
                                                    </telerik:RadDatePicker>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 110px">
                                                    Technician: </td>
                                                <td>
                                                    <asp:DropDownList ID="ddl_IDAssignedTech" runat="server" 
                                                        AppendDataBoundItems="True" DataSourceID="sds_Technician" 
                                                        DataTextField="FullName" DataValueField="ActiveDirID" 
                                                        Text='<%# Bind("IDAssignedTech") %>'>
                                                        <asp:ListItem Text="Select" Value="0" />
                                                        <asp:ListItem Text="Team" Value="1" />
                                                    </asp:DropDownList>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                                        ControlToValidate="ddl_IDAssignedTech" ErrorMessage="*" Font-Bold="True" 
                                                        Font-Size="Medium" ForeColor="#FF3300"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 110px">
                                                    Priority:</td>
                                                <td>
                                                    <telerik:RadRating ID="RadRating1" Runat="server" ReadOnly="True" 
                                                        Skin="WebBlue" Value='<%# Eval("Priority") %>'>
                                                    </telerik:RadRating>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 110px">
                                                    Project Deadline:</td>
                                                <td>
                                                    <telerik:RadDatePicker ID="RadDatePicker3" Runat="server" 
                                                        Culture="English (United States)" 
                                                        DbSelectedDate='<%# Bind("ResolutionDeadline") %>'>
                                                        <Calendar ID="Calendar3" Runat="server" UseColumnHeadersAsSelectors="False" 
                                                            UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                                        </Calendar>
                                                        <DatePopupButton HoverImageUrl="" ImageUrl="" />
                                                        <DateInput ID="DateInput3" Runat="server" DateFormat="M/d/yyyy" 
                                                            DisplayDateFormat="M/d/yyyy">
                                                        </DateInput>
                                                    </telerik:RadDatePicker>
                                                </td>
                                            </tr>
                                        </table>
                                        <h2>
                                            Project Details:</h2>
                                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                                            <tr>
                                                <td style="width: 101px">
                                                     </td>
                                                <td>
                                                    <asp:TextBox ID="tbx_Projects" runat="server" Text='<%# Bind("MasterProject") %>' 
                                                        Height="100px" TextMode="MultiLine" Width="625px" />
                                                </td>
                                            </tr>
                                        </table>
                                        <h2>
                                            Comments:</h2>
                                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                                            <tr>
                                                <td style="width: 101px">
                                                     </td>
                                                <td>
                                                    <asp:TextBox ID="tbx_Comment" runat="server" Text='<%# Bind("Comment") %>' 
                                                        Height="100px" TextMode="MultiLine" Width="625px" />
                                                </td>
                                            </tr>
                                        </table>
                                        <h2>
                                            Notes:</h2>
                                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                                            <tr>
                                                <td style="width: 101px">
                                                     </td>
                                                <td>
                                                    <asp:TextBox ID="tbx_Notes" runat="server" Text='<%# Bind("Notes") %>' 
                                                        Height="100px" TextMode="MultiLine" Width="625px" />
                                                </td>
                                            </tr>
                                        </table>
                                        <br />
                                        <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" 
                                            CommandName="Update" Text="Update" />
                                         <asp:Button ID="UpdateCancelButton" runat="server" 
                                            CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                                    </EditItemTemplate>
    <ItemTemplate>
                                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                                            <tr>
                                                <td>
                                                     </td>
                                            </tr>
                                        </table>
                                        <table cellpadding="3" cellspacing="0" style="width: 100%">
                                            <tr>
                                                <td class="tbltd" style="width: 112px">
                                                    Project Subject:</td>
                                                <td>
                                                  
                                                    <asp:Label ID="SubjectLabel" runat="server" style="font-weight: 700" 
                                                        Text='<%# Bind("Subject") %>' />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 112px">
                                                    Enter Date:</td>
                                                <td>
                                                    <asp:Label ID="EnterDateLabel" runat="server" 
                                                        Text='<%# Bind("EnterDate","{0:d}") %>' />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 112px">
                                                    Deadline Date:</td>
                                                <td>
                                                    <asp:Label ID="lbl_DealineDate" runat="server" 
                                                        Text='<%# Bind("ResolutionDeadline","{0:d}") %>' />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 112px">
                                                    Completion Date:</td>
                                                <td>
                                                    <asp:Label ID="ResolutionDateLabel" runat="server" 
                                                        Text='<%# Bind("ResolutionDate","{0:d}")  %>' />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 112px">
                                                    Technician: </td>
                                                <td>
                                                    <asp:Label ID="FullNameLabel" runat="server" 
                                                        Text='<%# Bind("FullName") %>' />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 112px">
                                                    Priority:</td>
                                                <td>
                                                    <telerik:RadRating ID="RadRating1" Runat="server" ReadOnly="True" 
                                                        Skin="WebBlue" Value='<%# Eval("Priority") %>'>
                                                    </telerik:RadRating>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tbltd" style="width: 112px">
                                                    Project Deadline:</td>
                                                <td>
                                                    <asp:Label ID="ResolutionDeadlineLabel" runat="server" 
                                                        Text='<%# Bind("ResolutionDeadline","{0:d}")  %>' />
                                                </td>
                                            </tr>
                                        </table>
                                        <h2>
                                            Project Details:</h2>
                                        <table cellpadding="0" cellspacing="0" style="width: 800px">
                                            <tr>
                                                <td style="width: 101px">
                                                     </td>
                                                <td>
                                                    <asp:Label ID="ProjectLabel" runat="server" Text='<%# Eval("MasterProject").ToString().Replace(Environment.NewLine,"<br />") %>' />
                                                </td>
                                            </tr>
                                        </table>
                                        <h2>
                                            Comments:</h2>
                                        <table cellpadding="0" cellspacing="0" style="width: 800px">
                                            <tr>
                                                <td style="width: 101px">
                                                     </td>
                                                <td>
                                                    <asp:Label ID="CommentLabel" runat="server" Text='<%# Eval("Comment").ToString().Replace(Environment.NewLine,"<br />") %>' />
                                                </td>
                                            </tr>
                                        </table>
                                        <h2>
                                            Notes:</h2>
                                        <table cellpadding="0" cellspacing="0" style="width: 800px">
                                            <tr>
                                                <td style="width: 101px">
                                                     </td>
                                                <td>
                                                    <asp:Label ID="NotesLabel" runat="server" Text='<%# Eval("Notes").ToString().Replace(Environment.NewLine,"<br />") %>' />
                                                </td>
                                            </tr>
                                        </table>
                                        <br />
        <asp:Button ID="EditButton" runat="server" CausesValidation="False" 
            CommandName="Edit" Text="Edit" />
         <asp:Button ID="Button2" runat="server" Text="Delete" onclick="Button2_Click" />
    </ItemTemplate>
</asp:FormView>


<asp:SqlDataSource ID="sds_MasterProjects" runat="server" 
    ConnectionString="<%$ ConnectionStrings:IT_CentralConnectionString %>" 
    DeleteCommand="DELETE FROM [ITC_ProjectsMaster]" 
    InsertCommand="" 
    SelectCommand="SELECT [IDProjectsMaster], [EnterDate], [ResolutionDeadline], [ResolutionDate], [FullName], [Subject], [MasterProject], [Priority], [Comment], [Notes], [IDAssignedTech] FROM [vw_ITC_Projects_Masters] WHERE [IDProjectsMaster] = @IDProjectsMaster" 
    UpdateCommand="UPDATE [ITC_Projects_Masters] SET [EnterDate] = @EnterDate, [ModifiedDate] = @ModifiedDate, [IDModifiedUser] = @IDModifiedUser, [ResolutionDeadline] = @ResolutionDeadline, [ResolutionDate] = @ResolutionDate, [IDAssignedTech] = @IDAssignedTech, [Subject] = @Subject, [MasterProject] = @MasterProject, [Priority] = @Priority, [Comment] = @Comment, [Notes] = @Notes WHERE [IDProjectsMaster] = @IDProjectsMaster">
    <InsertParameters>
        <asp:Parameter Name="EnterDate" Type="DateTime" />
    </InsertParameters>
    <SelectParameters>
        <asp:QueryStringParameter Name="IDProjectsMaster" QueryStringField="IDProjectsMaster" 
            Type="Int32" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="EnterDate" Type="DateTime" />
        <asp:Parameter Name="ModifiedDate" Type="DateTime" />
        <asp:Parameter Name="IDModifiedUser" Type="Int32" />
        <asp:Parameter Name="ResolutionDeadline" Type="DateTime" />
        <asp:Parameter Name="ResolutionDate" Type="DateTime" />
        <asp:Parameter Name="IDAssignedTech" Type="String" />
        <asp:Parameter Name="Subject" Type="String" />
        <asp:Parameter Name="MasterProject" Type="String" />
        <asp:Parameter Name="Priority" Type="Decimal" />
        <asp:Parameter Name="Comment" Type="String" />
        <asp:Parameter Name="Notes" Type="String" />
        <asp:Parameter Name="IDProjectsMaster" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>

My issue is that when I attempt to update the data, the rating is not updated and the field value is ste to null.

How can I use the Rating control in the update portion of the formview?

Thanks in advance.













1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 25 Jul 2011, 03:20 PM
Hello Allan,

I created a sample project, based on the code snippet that you sent and I was able to reproduce similar issue - after every update the value of the RadRating is lost. In order to solve the problem I made sure that the value of the rating is preserved by adding it to the update parameters in the Updating server-side event of SqlDataSource. The example below demonstrates this:
protected void Sqldatasource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
    e.Command.Parameters["@UnitsInStock"].Value = ((RadRating)Formview1.FindControl("UnitsInStock")).Value;
}
UnitsInStock is the ID of the RadSlider used in this example.

As the RadRating control usually accepts Value of type Decimal, please cast the specified value to that type:
<telerik:RadRating ID="UnitsInStock" runat="server" Skin="WebBlue" ReadOnly="true" Value='<%# Convert.ToDecimal(Eval("UnitsInStock")) %>'>

I have attached my test page so that you can use it as a basis for your further development.

If the information listed above does not help you resolve your difficulties please provide more detailed description of your scenario, as well as steps to reproduce the encountered problem.

Regards,
Slav
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Rating
Asked by
Allan
Top achievements
Rank 2
Answers by
Slav
Telerik team
Share this question
or