Link to home
Start Free TrialLog in
Avatar of ziwez0
ziwez0

asked on

Which Select


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

<a class=nav2 href="http://www.domain.com/Images.aspx?Cat=ALL">

---Images.aspx---

protected void Page_Load(object sender, EventArgs e)
    {
/////connection//////
        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";
        }

        else
        {

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

        }

Error:

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

Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

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"];
ASKER CERTIFIED SOLUTION
Avatar of GavinMannion
GavinMannion

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ziwez0
ziwez0

ASKER

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

thanks
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