Solved

Handle exception setting radio button selected item

Posted on 2010-08-24
5
408 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 400 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now