[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 502
  • Last Modified:

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

0
ziwez0
Asked:
ziwez0
  • 2
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
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"];
0
 
GavinMannionCommented:
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"]
0
 
ziwez0Author Commented:
opppss, it been a long day, lol (no excuse)

thanks
0
 
GavinMannionCommented:
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
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now