[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Handle exception setting radio button selected item

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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

873 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