Solved

reading newvalues

Posted on 2008-11-03
8
358 Views
Last Modified: 2012-05-05
I have a gridview and I used the following code to read the new values when updating data

string test = e.NewValues[3].ToString();

i got the following error.

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
0
Comment
Question by:Mr_Shaw
[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
  • 4
  • 4
8 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 22867602
How many columns does your gridview contains ? Remember that an index starts at 0 and not at 1

Perhaps this solves the problem: string test = e.NewValues[2].ToString();
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 22867619
if e.NewValues.Count >= 4 then
    string test = e.NewValues[3].ToString()
end if
0
 

Author Comment

by:Mr_Shaw
ID: 22867634
15 column of text, 1 hidden column and a edit/delet button/colum.

A screen shot is below.
gridview.bmp
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 53

Expert Comment

by:Dhaest
ID: 22867645
Did you try something like this:
e.NewValues["MyColumnName"].ToString()
0
 

Author Comment

by:Mr_Shaw
ID: 22867720
I tried

string test = e.NewValues["record_name"].ToString();

and got an error saying 'Object reference not set to an instance of an object.'

i ran a test to see how many columns the code thinks is present. I used

e.NewValues.Count

My result equaled 0

Therefore string test = e.NewValues[3].ToString() would never work. I am really stuck on this one!

0
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 22867749
in what event are you trying to capture your newvalues ?

Creating Audit Functionality Using ASP.NET 2.0
http://www.codeproject.com/KB/applications/CreateAuditFunction.aspx
0
 

Author Comment

by:Mr_Shaw
ID: 22867758
GridViewUpdateEventArgs
0
 

Author Comment

by:Mr_Shaw
ID: 22868081
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

737 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