Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Handle exception setting radio button selected item

Posted on 2010-08-24
5
Medium Priority
?
436 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
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…

647 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