• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5771
  • Last Modified:

Gridview Findcontrol

I'm using the following code to find a textbox:

txtM1Amt = e.Row.Controls(4).FindControl("txtM1Amt_add")

I inherited this application and I'm just curious as to how it works.  I follow that the row has a controls collection but I don't understand what controls are included.  If the user clicks "Edit" on this row and it brings up the update and cancel buttons, how does that affect the count of the controls.  I have this same code in the footer row and it works fine, not the case in the actual grid.

Thanks in advance,

N
0
stretch73
Asked:
stretch73
1 Solution
 
SQL_SERVER_DBACommented:
Dim txtM1Amt As String = _
              CType(row.FindControl("txtM1Amt_add"),TextBox).Text
            Response.Write(txtM1Amt)

0
 
stretch73Author Commented:
I'm adding a javascript to the control like this:

txtM1Amt.Attributes.Add("onkeypress", "return isNumberKey(event);")

It has more to do with making sure I get the correct control than the data inside of it
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now