Which Select

Posted on 2006-04-13
Last Modified: 2008-01-09

Ok have a .aspx page that has a list of links to view images, one link being view all images.

<a class=nav2 href="">


protected void Page_Load(object sender, EventArgs e)
        string objCatName;
        string SQL_sel_images;

        objCatName = Convert.ToString(Request.QueryString["Cat"]);

        if ( objCatName.ToString(Request.QueryString["Cat"]) = "ALL")
            SQL_sel_images = "SELECT * FROM table";


            SQL_sel_images = "SELECT * FROM table WHERE cat='" + objCatName + "'";



Compiler Error Message: CS1502: The best overloaded method match for 'string.ToString(System.IFormatProvider)' has some invalid arguments

Question by:ziwez0
    LVL 52

    Expert Comment

    by:Carl Tawn
    The ToString() method need a format providing. I think you are maybe just trying to cast to a string, in which case you can use:

        objCatName = (string)Request.QueryString["Cat"];
    LVL 15

    Accepted Solution

    These two lines make no sense

    objCatName = Convert.ToString(Request.QueryString["Cat"]);
    if ( objCatName.ToString(Request.QueryString["Cat"]) = "ALL")

    The first one is fine but then on the second just have

    if ( objCatName == "ALL")

    Since objCatName is already = tje Request.QueryString["Cat"]
    LVL 2

    Author Comment

    opppss, it been a long day, lol (no excuse)

    LVL 15

    Expert Comment

    hehe no problem, easiest points ever :)

    PS: I also find Request.QueryString["Cat"].ToString() easier to code... but as carl pointed out. You can do this many different ways. Whatever works best for you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 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

    10 Experts available now in Live!

    Get 1:1 Help Now