Solved

How to reference a bound column from RowUpdating of GridView control

Posted on 2008-09-29
3
593 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
[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
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

Industry Leaders: 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

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.…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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