?
Solved

Handle exception setting radio button selected item

Posted on 2010-08-24
5
Medium Priority
?
431 Views
Last Modified: 2012-05-10
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.


drFound = topicDetailsTable.Rows.Find(row.Row("ID"))
 If Not (drFound Is Nothing) Then
    rg.Items.FindByValue(drFound("TopicData")).Selected = True
 End If

Open in new window

0
Comment
Question by:sailing_12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:almander
ID: 33514763
Can you post the code with the non working Try/Catch?
0
 

Author Comment

by:sailing_12
ID: 33514861
Attached.

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

Open in new window

0
 
LVL 1

Expert Comment

by:narendragummadi
ID: 33520913
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

Open in new window

0
 

Author Comment

by:sailing_12
ID: 33521592
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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 2806: drFound = topicDetailsTable.Rows.Find(row.Row("ID"))
Line 2807: If Not (drFound Is Nothing) Then
Line 2808: rg.Items.FindByValue(drFound("TopicData")).Selected = True
Line 2809: End If
Line 2810: Catch ex As System.Web.Services.Protocols.SoapException

0
 
LVL 5

Accepted Solution

by:
almander earned 1600 total points
ID: 33524828
This is telling you that TopicData does not exist in the dsFround row.

Your catch is only catching SoapExceptions

You need to add a catch for other exceptions.
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
Catch exGeneral As Exception
 'Your handling code
End Try

Open in new window

0

Featured Post

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question