R
randy.buchholz
I am trying to trap the following error. I have tried to catch it on page
load and every event on the data source and dd. No luck.
I'm forcing the error by setting the dd.text to an invalid value on page
load which seems to be when the exception is thrown. How can I trap it?
Thanks.
Exception Details: System.ArgumentOutOfRangeException: 'DropDownList1' has a
SelectedValue which is invalid because it does not exist in the list of
items.
Parameter name: value
<aspropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="Certification"
DataValueField="Certification" Width="200px">
</aspropDownList>
<asp:Label ID="lbl_Error" runat="server" Text="Label"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:ToteConnection %>"
SelectCommand="SELECT [Certification] FROM [CertTypes]">
</asp:SqlDataSource>
protected void Page_Load(object sender, EventArgs e)
{
try
{
DropDownList1.Text = "hello";
}
catch (ArgumentOutOfRangeException ar)
{
lbl_Error.Text = ar.Message;
}
catch (Exception ex)
{
lbl_Error.Text = ex.Message;
}
}
protected void SqlDataSource1_Event??(object sender, EventArgs e)
{
try
{
DropDownList1.Text = "hello";
}
catch (ArgumentOutOfRangeException ar)
{
lbl_Error.Text = ar.Message;
}
catch (Exception ex)
{
lbl_Error.Text = ex.Message;
}
}
protected void SqlDataSource1_Event??(object sender, EventArgs e)
{
try
{
DropDownList1.Text = "hello";
}
catch (ArgumentOutOfRangeException ar)
{
lbl_Error.Text = ar.Message;
}
catch (Exception ex)
{
lbl_Error.Text = ex.Message;
}
}
load and every event on the data source and dd. No luck.
I'm forcing the error by setting the dd.text to an invalid value on page
load which seems to be when the exception is thrown. How can I trap it?
Thanks.
Exception Details: System.ArgumentOutOfRangeException: 'DropDownList1' has a
SelectedValue which is invalid because it does not exist in the list of
items.
Parameter name: value
<aspropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="Certification"
DataValueField="Certification" Width="200px">
</aspropDownList>
<asp:Label ID="lbl_Error" runat="server" Text="Label"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:ToteConnection %>"
SelectCommand="SELECT [Certification] FROM [CertTypes]">
</asp:SqlDataSource>
protected void Page_Load(object sender, EventArgs e)
{
try
{
DropDownList1.Text = "hello";
}
catch (ArgumentOutOfRangeException ar)
{
lbl_Error.Text = ar.Message;
}
catch (Exception ex)
{
lbl_Error.Text = ex.Message;
}
}
protected void SqlDataSource1_Event??(object sender, EventArgs e)
{
try
{
DropDownList1.Text = "hello";
}
catch (ArgumentOutOfRangeException ar)
{
lbl_Error.Text = ar.Message;
}
catch (Exception ex)
{
lbl_Error.Text = ex.Message;
}
}
protected void SqlDataSource1_Event??(object sender, EventArgs e)
{
try
{
DropDownList1.Text = "hello";
}
catch (ArgumentOutOfRangeException ar)
{
lbl_Error.Text = ar.Message;
}
catch (Exception ex)
{
lbl_Error.Text = ex.Message;
}
}