The main exception (HttpUnhandledException) would never give you a very good message of what the problem is. The problem in this context is in the inner message. Inner message states,
Quote:
Input string was not in a correct format.
So, the solution is that you are not providing a string value that can be converted to integer value. Your variable type is not a problem. I believe it is being thrown at,
Convert.ToInt32(Request.QueryString["brand"]);
You need to check what value is being passed as "
Request.QuerySring["brand"]
". It must be a numeric value. Instead of this, I would try using the
int.TryParse(string, out int)
[
^] method which would check whether the number can be converted to integer or not.
It won't break your application.
int brandId = 0;
int.TryParse(Request.QueryString["brand"], out brandId);
This code would minimize the exception chances now and would allow you to use a condition. Something like this,
int brandId = 0;
if(int.TryParse(Request.QueryString["brand"], out brandId)) {
} else {
}
Value is stored in the "
brandId
" variable of your application.