M
MU
Hello
I have some code that sets a dropdownlist control with a parameter
from the querystring. However, when the querystring is empty, I get
an error.
Here is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim intProductID As Integer = Trim(Request("productid"))
If IsNumeric(intProductID) Then
drpProducts.SelectedValue = intProductID
End If
End If
End Sub
Here is the error:
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a
correct format.
Source Error:
Line 18: Protected Sub Page_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Load
Line 19: If Not Page.IsPostBack Then
Line 20: Dim intProductID As Integer =
Trim(Request("productid"))
How do I just have it continue without giving me the error?
Thanks
I have some code that sets a dropdownlist control with a parameter
from the querystring. However, when the querystring is empty, I get
an error.
Here is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim intProductID As Integer = Trim(Request("productid"))
If IsNumeric(intProductID) Then
drpProducts.SelectedValue = intProductID
End If
End If
End Sub
Here is the error:
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a
correct format.
Source Error:
Line 18: Protected Sub Page_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Load
Line 19: If Not Page.IsPostBack Then
Line 20: Dim intProductID As Integer =
Trim(Request("productid"))
How do I just have it continue without giving me the error?
Thanks