Solved

How to reference a bound column from RowUpdating of GridView control

Posted on 2008-09-29
3
590 Views
Last Modified: 2013-11-07
Dear Experts,
I have a GridView I use for tracking shift times in a time clock application. If a user edits a row, I want to track the changes. In the RowUpdating event of the GV, I am simply trying to reference a bound column ("STShiftTimeID") to pass to my update table. I have tried:
DirectCast(gvShiftTimes.FindControl("STShiftTimeID"),Label) - using STShiftTime as a bound column;
DirectCast(gvShiftTimes.FindControl("txtSTShiftTimeID"),TextBox) - using txtSTShiftTimeID as a text box in a template and keep getting the NullReferenceException error. I have checked spelling and no typos.
I also check the e.Keys, e.NewValues, and e.OldValues of the Time-In and Time-Out controls, which work fine. If I try to find the STShiftTimeID value using either of those e values, it just comes back as zero, though I can see the STShiftTimeID in the grid.
So Experts, please, how do I reference the STShiftTimeID in my gridview control?
Thank you.
Dim tbxSTShiftTimeID As TextBox = CType(gvShiftTimes.FindControl("txtSTShiftTimeID"), TextBox)
        Dim iShiftTimeID As Integer = 0
        If tbxSTShiftTimeID.Text IsNot Nothing Then
            iShiftTimeID = tbxSTShiftTimeID.text
        End If

Open in new window

0
Comment
Question by:MCallas
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
ID: 22600655
Change this line to the attached snippet:
Dim tbxSTShiftTimeID As TextBox = CType(gvShiftTimes.FindControl("txtSTShiftTimeID"), TextBox)
 

Dim row As GridViewRow = Me.gvMemberLogs.Rows(e.RowIndex)
Dim tbxSTShiftTimeID As TextBox = CType(row.FindControl("txtSTShiftTimeID"), TextBox)

Open in new window

0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22600664
Sorry, change "gvMemberLogs" to "gvShiftTimes"
0
 

Author Closing Comment

by:MCallas
ID: 31501365
Thanks, prairiedog, for your quick and accurate reply (and for restoring what was left of my sanity).
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

16 Experts available now in Live!

Get 1:1 Help Now