Rotator with LinqDataSource - The 'DataSource' property cannot be set declaratively.

4 posts, 0 answers
  1. Mych
    Mych avatar
    18 posts
    Member since:
    Sep 2012

    Posted 25 Jul 2013 Link to this post

    Hi, I have used an example from the demos to created a 'Scores' type ticker...

    My markup is...

    <telerik:RadRotator ID="RadRotator1" runat="server" DataSource="LinqDataSource1"
        FrameDuration="2000" Height="20px" ItemHeight="20" Width="570px" ItemWidth="570"
        ScrollDuration="2000" ScrollDirection="Up">
        <ItemTemplate>
            <div class="results">
                <table class="rTable">
                    <tr>
                        <td class="leftCell">
                            <asp:Literal ID="lit_Title" runat="server" Text='<%= Bind("Title")%>'></asp:Literal>
                        </td>
                        <td class="figure">
                            <asp:Literal ID="lit_Total" runat="server" Text='<%= Bind("Total") %>'></asp:Literal>
                        </td>
                        <td class="figure">
                            <asp:Literal ID="lit_TypeA" runat="server" Text='<%= Bind("TypeA") %>'></asp:Literal>
                        </td>
                        <td class="figure">
                            <asp:Literal ID="lit_TypeB" runat="server" Text='<%= Bind("TypeB") %>'></asp:Literal>
                        </td>
                        <td class="figure">
                            <asp:Literal ID="lit_TypeC" runat="server" Text='<%= Bind("TypeC")%>'></asp:Literal>
                        </td>
                        <td class="figure">
                            <asp:Literal ID="lit_TypeD" runat="server" Text='<%= Bind("TypeD") %>'></asp:Literal>
                        </td>
                        <td class="figure">
                            <asp:Literal ID="lit_TypeE" runat="server" Text='<%= Bind("TypeE") %>'></asp:Literal>
                        </td>
                    </tr>
                </table>
            </div>
        </ItemTemplate>
    </telerik:RadRotator>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" OnSelecting="LinqDataSource1_Selecting">
    </asp:LinqDataSource>

    And my codebehind has...

    Protected Sub LinqDataSource1_Selecting(sender As Object, e As LinqDataSourceSelectEventArgs) Handles LinqDataSource1.Selecting
      
        Dim db As New TestDataContext
      
        Dim tickerquery As New StringBuilder
      
        tickerquery.Append("DECLARE @ALL_Total int ")
        tickerquery.Append("DECLARE @ABC_Total int ")
        tickerquery.Append("DECLARE @XYZ_Total int ")
        tickerquery.Append("DECLARE @ALL_TypeA int ")
        tickerquery.Append("DECLARE @ABC_TypeA int ")
        tickerquery.Append("DECLARE @XYZ_TypeA int ")
        tickerquery.Append("DECLARE @ALL_TypeB int ")
        tickerquery.Append("DECLARE @ABC_TypeB int ")
        tickerquery.Append("DECLARE @XYZ_TypeB int ")
        tickerquery.Append("DECLARE @ALL_TypeC int ")
        tickerquery.Append("DECLARE @ABC_TypeC int ")
        tickerquery.Append("DECLARE @XYZ_TypeC int ")
        tickerquery.Append("DECLARE @ALL_TypeD int ")
        tickerquery.Append("DECLARE @ABC_TypeD int ")
        tickerquery.Append("DECLARE @XYZ_TypeD int ")
        tickerquery.Append("DECLARE @ALL_TypeE int ")
        tickerquery.Append("DECLARE @ABC_TypeE int ")
        tickerquery.Append("DECLARE @XYZ_TypeE int ")
      
        tickerquery.Append("DECLARE @ALL_Title nvarchar(3) ")
        tickerquery.Append("DECLARE @ABC_Title nvarchar(3) ")
        tickerquery.Append("DECLARE @XYZ_Title nvarchar(3) ")
        tickerquery.Append("SET @ALL_Title = 'ALL' ")
        tickerquery.Append("SET @ABC_Title = 'ABC' ")
        tickerquery.Append("SET @XYZ_Title = 'XYZ' ")
        tickerquery.Append("DECLARE @Count_Tbl table (Title nvarchar(3), Total int, TypeA int, TypeB int, TypeC int, TypeD int, TypeE int) ")
      
        tickerquery.Append("SELECT @ALL_Total = (SELECT Count(ProdID) FROM Products) ")
        tickerquery.Append("SELECT @ABC_Total = (SELECT Count(ProdID) FROM Products WHERE Category = 'ABC') ")
        tickerquery.Append("SELECT @XYZ_Total = (SELECT Count(ProdID) FROM Products WHERE Category = 'XYZ') ")
        tickerquery.Append("SELECT @ALL_TypeA = (SELECT Count(ProdID) FROM Products WHERE Productstatus = 'TypeA') ")
        tickerquery.Append("SELECT @ABC_TypeA = (SELECT Count(ProdID) FROM Products WHERE Category = 'ABC' AND Productstatus = 'TypeA') ")
        tickerquery.Append("SELECT @XYZ_TypeA = (SELECT Count(ProdID) FROM Products WHERE Category = 'XYZ' AND Productstatus = 'TypeA') ")
        tickerquery.Append("SELECT @ALL_TypeB = (SELECT Count(ProdID) FROM Products WHERE Productstatus = 'TypeB') ")
        tickerquery.Append("SELECT @ABC_TypeB = (SELECT Count(ProdID) FROM Products WHERE Category = 'ABC' AND Productstatus = 'TypeB') ")
        tickerquery.Append("SELECT @XYZ_TypeB = (SELECT Count(ProdID) FROM Products WHERE Category = 'XYZ' AND Productstatus = 'TypeB') ")
        tickerquery.Append("SELECT @ALL_TypeC = (SELECT Count(ProdID) FROM Products WHERE Productstatus = 'TypeC') ")
        tickerquery.Append("SELECT @ABC_TypeC = (SELECT Count(ProdID) FROM Products WHERE Category = 'ABC' AND Productstatus = 'TypeC') ")
        tickerquery.Append("SELECT @XYZ_TypeC = (SELECT Count(ProdID) FROM Products WHERE Category = 'XYZ' AND Productstatus = 'TypeC') ")
        tickerquery.Append("SELECT @ALL_TypeD = (SELECT Count(ProdID) FROM Products WHERE Productstatus = 'TypeD') ")
        tickerquery.Append("SELECT @ABC_TypeD = (SELECT Count(ProdID) FROM Products WHERE Category = 'ABC' AND Productstatus = 'TypeD') ")
        tickerquery.Append("SELECT @XYZ_TypeD = (SELECT Count(ProdID) FROM Products WHERE Category = 'XYZ' AND Productstatus = 'TypeD') ")
        tickerquery.Append("SELECT @ALL_TypeE = (SELECT Count(ProdID) FROM Products WHERE Productstatus <> 'TypeD') ")
        tickerquery.Append("SELECT @ABC_TypeE = (SELECT Count(ProdID) FROM Products WHERE Category = 'ABC' AND Productstatus = 'TypeE') ")
        tickerquery.Append("SELECT @XYZ_TypeE = (SELECT Count(ProdID) FROM Products WHERE Category = 'XYZ' AND Productstatus = 'TypeE') ")
      
        tickerquery.Append("INSERT INTO @Count_Tbl (Title, Total, TypeA, TypeB, TypeC, TypeD, TypeE SELECT @ALL_Title, @ALL_Total, @ALL_TypeA, @ALL_TypeB, @ALL_TypeC, @ALL_TypeD, @ALL_TypeE ")
      
        tickerquery.Append("INSERT INTO @Count_Tbl (Title, Total, TypeA, TypeB, TypeC, TypeD, TypeE SELECT @ABC_Title, @ABC_Total, @ABC_TypeA, @ABC_TypeB, @ABC_TypeC, @ABC_TypeD, @ABC_TypeE ")
      
        tickerquery.Append("INSERT INTO @Count_Tbl (Title, Total, TypeA, TypeB, TypeC, TypeD, TypeE SELECT @XYZ_Title, @XYZ_Total, @XYZ_TypeA, @XYZ_TypeB, @XYZ_TypeC, @XYZ_TypeD, @XYZ_TypeE ")
      
        tickerquery.Append("SELECT Title, Total, TypeA, TypeB, TypeC, TypeD, TypeE FROM @Count_Tbl")
      
        Dim results As IEnumerable(Of ProductCount) = _
            db.ExecuteQuery(Of ProductCount) _
            (tickerquery.ToString)
      
        e.Result = results
    End Sub

    Why do I get the error message -

    The 'DataSource' property cannot be set declaratively ..... any help appreciated.

  2. Mych
    Mych avatar
    18 posts
    Member since:
    Sep 2012

    Posted 25 Jul 2013 Link to this post

    OK as soon as I posted I saw my mistake.... it should be DataSourceID = "LinqDataSource1" and not DataSource = "LinqDataSource1".

    I now have a problem with the SQL statement which I know works on its own but when used with LINQ I get a Syntax error 'SELECT SELECT SELECT'

    As this is not a Telerik issue I don't suppose anyone can help... Is there any other way I can get the results from the SQL I have created to bind to the ticket?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mych
    Mych avatar
    18 posts
    Member since:
    Sep 2012

    Posted 25 Jul 2013 Link to this post

    OK... the SELECT errors came about from when I was converting my sql into as series of .appends to the stringbuilder. I inadvertantly deleted 3 closing brackets

    I had
    INSERT INTO @Count_Tbl (Title, Total, TypeA, TypeB, TypeC, TypeD, TypeE SELECT @ALL_Title, @ALL_Total, @ALL_TypeA, @ALL_TypeB, @ALL_TypeC, @ALL_TypeD, @ALL_TypeE
    and I should have had
    INSERT INTO @Count_Tbl (Title, Total, TypeA, TypeB, TypeC, TypeD, TypeE) SELECT @ALL_Title, @ALL_Total, @ALL_TypeA, @ALL_TypeB, @ALL_TypeC, @ALL_TypeD, @ALL_TypeE

    My page now runs ok, no errors but the ticker data does not display.

    In my view source I get 3 rows but where the data should be I'm getting
    <li class="rrItem" style="height:20px;width:570px;">
        <
    div id="RadRotator1_i2">
    <div class="results">
                                            <table class="rTable">
                                                <tr
                                                    <td class="leftCell"
                                                        <%= Bind("Title")%> 
                                                    </td
                                                    <td class="figure"
                                                        <%= Bind("Total") %> 
                                                    </td
                                                    <td class="figure"
                                                        <%= Bind("TypeA") %> 
                                                    </td
                                                    <td class="figure"
                                                        <%= Bind("TypeB") %> 
                                                    </td
                                                    <td class="figure"
                                                        <%= Bind("TypeC")%> 
                                                    </td
                                                    <td class="figure"
                                                        <%= Bind("TypeD") %> 
                                                    </td
                                                    <td class="figure"
                                                        <%= Bind("TypeE") %> 
                                                    </td
                                                </tr
                                            </table>
                                        </div>
                                      
                            </div></li>
    3 times.... I have used Bind and Eval with no diffrence in display.

    Any ideas anyone?
  5. Mych
    Mych avatar
    18 posts
    Member since:
    Sep 2012

    Posted 25 Jul 2013 Link to this post

    Fixed.... I'm having one of those days..... I should have used <%# Eval("Fieldname")%> and not <%=

    All works... have a lovely ticker ticking away... :)
Back to Top