Solved

GridView SelectedDataKey Error

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c#, datatable, aspx 4 45
C# rename a class and update all references efficiently 6 47
Data Analysis 7 57
e commerce steps shown instead of self testing 2 50
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

740 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