Solved

How to reference a bound column from RowUpdating of GridView control

Posted on 2008-09-29
3
587 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
Comment Utility
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
Comment Utility
Sorry, change "gvMemberLogs" to "gvShiftTimes"
0
 

Author Closing Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.…
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:…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

12 Experts available now in Live!

Get 1:1 Help Now