RadRating not firing Rate from RadGrid

3 posts, 0 answers
  1. Nikita Yaroshevsky
    Nikita Yaroshevsky avatar
    21 posts
    Member since:
    Apr 2010

    Posted 28 Jan 2011 Link to this post

    Hi I have a problem with RadRating control.

    I have a RadGrid in which there is a <ItemTemplate> section that allows to define the look of the unit displayed on the grid. In it, I want to add RadRating control and ultimately be able to rate a unit and make a call to a database to update a rating field WITHOUT reloading the page. (using Update Panel)

    So the very first thing I did was to add the control to the <itemTemplate> like it is shown in your examples. However, the control is not added to the list of recognizable controls to call methods on ( from codebehind) and it is not added to the designer file of the control. So there is no way either Update panel or codebehind will be able to reference the rating control.

    How do I go around that?

    What I have noticed was that if I add the control outside <itemTemplate> it will register control properly as well as add it to the list of  possible objects to do declarations on (from CodeBehind)

    Here is my code:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
               <AjaxSettings>
                  <telerik:AjaxSetting AjaxControlID="RadGrid1">
                       <UpdatedControls>
                           <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                       </UpdatedControls>
                   </telerik:AjaxSetting>
               </AjaxSettings>
           </telerik:RadAjaxManager>
            
      
           <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
               Width="75px" Transparency="5">
               <img style="margin-top: 150px;" alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading4.gif") %>' />
           </telerik:RadAjaxLoadingPanel>
            
          
       
                 
          
                <telerik:RadGrid ID="RadGrid1" EnableViewState="False" OnPageIndexChanged="RadGrid1_PageIndexChanged"
                    runat="server" DataSourceID="SqlDataSource1" GridLines="None" Width="850px" Height="100%"
                    Skin="Telerik" PageSize="20" AllowPaging="True">
                    <PagerStyle Mode="NumericPages" PageButtonCount="1" Position="TopAndBottom" />
                    <MasterTableView BorderStyle="None" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
                        PageSize="20">
                        <NoRecordsTemplate>
                            <div>
                                Nothing was found, start your search again. To Refresh, click <a href="inventory.aspx?reset=no&make=clear&model=clear&yearFromGrid=clear">
                                    here</a></div>
                        </NoRecordsTemplate>
                        <Columns>
                            <telerik:GridBoundColumn DataField="ID" HeaderText="ID" SortExpression="ID" UniqueName="ID"
                                DataType="System.Int32" ReadOnly="True" Visible="False" AutoPostBackOnFilter="True">
                            </telerik:GridBoundColumn>
                        </Columns>
                         
                        <ItemTemplate>
                            <div style="height: auto; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px;">
                                <table width="95%" border="0" cellspacing="0" cellpadding="0">
                                    <tr style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                        <td style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                            <div style="font-size: medium; font-weight: bold; text-align: left;">
                                                  <a class="nikfont2" style="color: black; font-size: medium;"><%#Eval("Year") & " " & Eval("Make") & " " & Eval("Model") %></a></div>
                                        </td>
                                        <tr style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                            <td style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                <table border="0">
                                                    <tr style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                        <td style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                            <div runat="server" visible="false" id="myDiv">
                                                                <%#Eval("Stock Number") %></div>
                                                            <br />
                                                        </td>
                                                        <td style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                            <a href="productdetails.aspx?sid=<%#Eval("Stock Number") %>&sysn=<%#Eval("Sys2KNum") %>">
                                                                <img id="imgItem1" alt="" src="<%# GetJobImageHtml(DirectCast(Eval("Stock Number"), String), DirectCast(Eval("PicturePackage"), String),DirectCast(Eval("Sys2KNum"), String) )%>"
                                                                    style="width: 120px; border: 1px solid rgb(195, 195, 195);" />
                                                            </a>
                                                        </td>
                                                        <td style="text-align: left; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                            <table style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                                <tr style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                                    <td width="60px">
                                                                        Stock #:<br />
                                                                        Int Color:<br />
                                                                        UVW:<br />
                                                                        Length:<br />
                                                                        Category:<br />
                                                                         
                                                                    </td>
                                                                    <td width="100px" style="">
                                                                        <%#eval("Stock Number") %><br />
                                                                        <%# Eval("Color")%><br />
                                                                        <%# Eval("Weight")%><br />
                                                                        <%# LengthOuputer(DirectCast(myCStr(Eval("Length")), String))%><br />
                                                                        <%# Eval("InternetClass") %><br />
                                                                    </td>
                                                                    
                                                                </tr>
                                                                <tr style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                                    <td colspan="4" style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                                        <span id="lblDescription">
                                                                             <%--IIf(myCStr(Eval("Sales Description")) <> "", myCStr(Eval("Sales Description")).ToString().Substring(0, Math.Min(150, myCStr(Eval("Sales Description")).Length)) & "...  <a href=""productdetails.aspx?sid=" & myCStr(Eval("Stock Number")) & """>[View More]</a>", "")--%>
                                                                        </span>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                        <td width="250px">
                                                            <table style="border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px">
                                                                <tr>
                                                                     
                                                                    <td>
                                                                     <%# loadAddress(DirectCast(myCStr(Eval("Address1")), String), _
                                                                                                                                                 DirectCast(myCStr(Eval("Address2")), String), _
                                                                                                                                                 DirectCast(myCStr(Eval("City")), String), _
                                                                                                                                                 DirectCast(myCStr(Eval("State")), String), _
                                                                                                                                                 DirectCast(myCStr(Eval("Zip")), String), _
                                                                                                                                                 DirectCast(myCStr(Eval("MainPhone")), String))%>
                                                                       
                                                                      
                                                                         
                                                                                    <telerik:RadRating ID="RadRating1" runat="server" AutoPostBack="False" OnRate="RadRating1_Rate"  Precision="Exact"  />
                                                                              
     
                                                                        <%--<telerik:RadRating ID="RadRating1" runat="server" AutoPostBack="True" OnRate="RadRating1_Rate"  Precision="Exact"  />--%>
                                                                        
                                                                       <%-- <telerik:RadComboBox ID="RadComboBox1" runat="server" OnSelectedIndexChanged="RadRating1_Rate">
                                                                             <Items>
                                                                                <telerik:RadComboBoxItem runat="server" Text="Select Criteria" Value="none" Selected="True" />
                                                                                <telerik:RadComboBoxItem runat="server" Text="Length Ascending" Value="LengthA" Selected="False" />
                         
                                                                              </Items>
                                                                        </telerik:RadComboBox>--%>
                                                                        
                                                                           
                                                                    </td>
                                                                    <td width="120px">
                                                                        <div style="font-size: large; font-weight: bold; vertical-align: top">
                                                                            <%# price(DirectCast(myCStr(Eval("SalePrice")), String), _
                                                                            DirectCast(myCStr(Eval("Suggested Selling Price")), String), _
                                                                            DirectCast(myCStr(Eval("OurPrice")), String), _
                                                                            DirectCast(myCStr(Eval("SpecialPrice")), String), _
                                                                            DirectCast(myCStr(Eval("MSRP")), String), _
                                                                            DirectCast(myCStr(Eval("Sys2KNum")), String))%>
                                                                        </div>
                                                                         <div >
                                                                            <a href="productdetails.aspx?sid=<%#Eval("Stock Number") %>&sysn=<%#Eval("Sys2KNum") %>">
                                                                                <img src="images/viewdetails.png" alt="" name="<%#Eval("Stock Number") %>" border="0"
                                                                                    style="margin-bottom: 5px" /></a><br />
                                                                        </div>
                                                                        <br />
                                                                        <div>
                                                                            <%# zip(DirectCast(myCStr(Eval("Radius")), String), DirectCast(myCStr(Eval("DealerCity")), String))%>
                                                                        </div>
                                                                    </td>
                                                                     
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                </table>
                            </div>
                        </ItemTemplate>
                        <EditFormSettings>
                            <FormTemplate>
                            </FormTemplate>
                        </EditFormSettings>
                        <PagerStyle Mode="NumericPages" Position="TopAndBottom" />
                    </MasterTableView>
                    <ActiveItemStyle BorderStyle="None" />
                </telerik:RadGrid>
            </td>
        </tr>
    </table>
     
     
     
     
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:TestString %>"
        SelectCommand="SELECT * FROM Vehicles WHERE Sys2KNum = '007414'" >
    </asp:SqlDataSource>

  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 02 Feb 2011 Link to this post

    Hello Nikita Yaroshevsky,
    Please refer to our online documentation for information and code samples, demonstrating how you can get a reference to the controls in the grid rows - http://www.telerik.com/help/aspnet-ajax/gridreferencecontrolsinroweditform.html.

    Greetings,
    Tsvetie
    the Telerik team
    Browse the vast support resources we have to jump start 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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nikita Yaroshevsky
    Nikita Yaroshevsky avatar
    21 posts
    Member since:
    Apr 2010

    Posted 03 Feb 2011 Link to this post

    Yes it worked, I have taken it out of itemtemplate AND turned on the viewstate on the grid. Thanks for help!
Back to Top