asp where parameter for linq query

Posted on 2008-11-05
Last Modified: 2013-11-11
Here is my scenario.  I have an aspx webpage that has a dropdown in the form.  I am populating the dropdown with a view that is in my dataclasses file.  This view is just a list of years, but for the particular form I am using i need to filter the results of that view.  From the dropdown i have configured a linqdatasource.  in that wizard i selected to add some parameters to the where clause.  this works as expected when specifing year less than 2000 and greater than 1955; however, what i need to do is include all years less than current year - 9 and greater than current year - 50.  

what i think i should be able to do is something similar to select year(getdate())-9 as the default value; however, when doing so i get an error "Input string was not in a correct format"

please advise.  
<asp:DropDownList ID="BirthYear" runat="server" AppendDataBoundItems="True" 

        Width="180px" DataSourceID="LinqDataSource_DropDown_BirthYear" DataTextField="intYear" 


            <asp:ListItem Selected="True" Value="0">Choose One</asp:ListItem>



        <asp:LinqDataSource ID="LinqDataSource_DropDown_BirthYear" runat="server" 


        Select="new (intYear)" TableName="viewDropDown_Years" 

        Where="intYear &lt; @intYear &amp;&amp; intYear &gt; @intYear1">


                <asp:Parameter DefaultValue="2000" Name="intYear" Type="Int32" />

                <asp:Parameter DefaultValue="1955" Name="intYear1" Type="Int32" />



Open in new window

Question by:rugby148
    1 Comment

    Accepted Solution

    I found a solution.  i did not need to use the parameter.  I could just put what i needed in the where property of the linkdatasource.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    network + 7 60
    Jquery oncheck to update SPAN 31 35
    Xamarin 10 20
    Can I play with MicroStrategy.NET without a license? 5 21
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now