Solved

GridView SelectedDataKey Error

Posted on 2007-11-28
2
857 Views
Last Modified: 2013-11-07
I have used this on tons of gridviews

Session("ScheduleID") = CaseEventsGridView.SelectedDataKey.Value

This time I am getting an error
System.NullReferenceException: Object reference not set to an instance of an object.
I cannot understand why it is null?  THere is data in the grid and I can see the ID.

Please help!!
0
Comment
Question by:vzorn
2 Comments
 
LVL 22

Accepted Solution

by:
RedKelvin earned 500 total points
ID: 20371146
This will happen if the dataKeyNames are not set, or no row is selected
0
 

Author Comment

by:vzorn
ID: 20375088
I see.  I was using the RowCommand event and I needed to get the row first.

Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

22 Experts available now in Live!

Get 1:1 Help Now