Sailing_12
asked on
Handle exception setting radio button selected item
The code below returns an 'Object reference not set to an instance of an object' error if the TopicData value is no longer an option on the rg radio button list.
I'm not sure how to handle this exception - try/catch does not seem to work.
can someone help?
Thanks.
I'm not sure how to handle this exception - try/catch does not seem to work.
can someone help?
Thanks.
drFound = topicDetailsTable.Rows.Find(row.Row("ID"))
If Not (drFound Is Nothing) Then
rg.Items.FindByValue(drFound("TopicData")).Selected = True
End If
Can you post the code with the non working Try/Catch?
ASKER
Attached.
Still get server error with this in place.
Still get server error with this in place.
drFound = topicDetailsTable.Rows.Find(row.Row("ID"))
If Not (drFound Is Nothing) Then
Try
rg.Items.FindByValue(drFound("TopicData")).Selected = True
Catch ex As System.Web.Services.Protocols.SoapException
CrmServiceUtility.LogError(IO.Path.GetFileName(Request.PhysicalPath) + " | " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex)
End Try
End If
Try this way
Try
drFound = topicDetailsTable.Rows.Find(row.Row("ID"))
If Not (drFound Is Nothing) Then
rg.Items.FindByValue(drFound("TopicData")).Selected = True
End If
Catch ex As System.Web.Services.Protocols.SoapException
'Your Handling Code
End Try
ASKER
Nope - Still returns error:
Server Error in '/' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Object reference not set to an instance of an object.
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.NullReferenceExcept ion: Object reference not set to an instance of an object.
Source Error:
Line 2806: drFound = topicDetailsTable.Rows.Fin d(row.Row( "ID"))
Line 2807: If Not (drFound Is Nothing) Then
Line 2808: rg.Items.FindByValue(drFou nd("TopicD ata")).Sel ected = True
Line 2809: End If
Line 2810: Catch ex As System.Web.Services.Protoc ols.SoapEx ception
Server Error in '/' Application.
--------------------------
Object reference not set to an instance of an object.
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.NullReferenceExcept
Source Error:
Line 2806: drFound = topicDetailsTable.Rows.Fin
Line 2807: If Not (drFound Is Nothing) Then
Line 2808: rg.Items.FindByValue(drFou
Line 2809: End If
Line 2810: Catch ex As System.Web.Services.Protoc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.