Hi all,
I am fairly new to c# and asp.net and am having an issue converting type;
My situation is that I have a search engine that has a textbox for the search text and two radio buttons for the search location ( IE City1 or City2 )
When I recieve the search text and radio buttons they are in the form of a string IE
string thesearchtext, thecitytype;
thesearchtext = HttpContext.Current.Request.QueryString["s"].ToString();
thecitytype = HttpContext.Current.Request.QueryString["bt"].ToString();
When I recieve the cities radiobutton they will be in the format of "city1" or "city2".
What i need to do is convert the city radiobuttons into an int so that I can use them in my search dataset. IE I need to convert "city" to "1" and "city2" to "2".
I understand this is probably a simple type conversion however I just cannot figure it out. I tried an "if" statement to convert the cities but I keep getting:
cannot implicitly convert type 'string' to 'bool'
I was trying code like this:
int listingsToSearch;
if (thecitytype = "City1")
{
listingsToSearch = Convert.ToInt32(1);
}
else
{
listingsToSearch = Convert.ToInt32(2);
}
Any help in guiding me in the right direction would be greatly appreciated Thanks...