Solved

GridView SelectedDataKey Error

Posted on 2007-11-28
2
887 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
[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 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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