Form view question

If I use a form view component how do I referance that field in vb

example formview1  has a field called "name"  when I try to referance this field in the vb source. it tell me that name is not declared
jfgrayiiiAsked:
Who is Participating?
 
jake072Commented:
Ok...

What I would do is iterate through all of the controls on the form, and add them into the FormView...

private ctrl As Control()

For Each ctrl As Control In Me.Controls
    If ctrl Is Nothing Then
        ReDim ctrl(0)
    Else
        ReDim Preserve ctrl(ctrl.Length)
    End If
    ctrl(ctrl.Length -1) = ctrl
Next

Now, add the ctrl array to the FormView, and voila, you can access any controls in your form.

Let me know if you need more help.

Jake
0
 
jake072Commented:
I'm not sure I understand what you mean by "field"...  Do you mean Property?  If so, make sure it's accessible outside the class

Jake
0
 
jfgrayiiiAuthor Commented:
If I have a textbox out of a form view I can type

me.textbox1.text = "blah blah"

If that text box is used in a form view  or data grid

me.textbox1 will say not declared

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
jake072Commented:
me.parent.textbox1.text = "blah blah"

You have to refer to the parent of your control (the form), and then access it's controls.

Jake
0
 
jfgrayiiiAuthor Commented:
how would I referance a field from

sqldatasource1
 in
formview1 ?
0
 
jake072Commented:
You can set it when you create the FormView1...

For Instance, you could say (in FormView1):

Private SqlDataSource1 As SqlDataSource

Sub New(ByRef SqlDataSource1 As SqlDataSource)
    Me.SqlDataSource1 = SqlDataSource1
End Sub

Now you can access SqlDataSource1 from your FormView1.

Hope that helps,

Jake
0
 
jfgrayiiiAuthor Commented:
If I drop a text box on a form I can double click on that box and write vb code

example.

me.textbox1.text = "0"

If I insert a form view component right click on it, go to edit templete, and add a textbox and double click on it
me.textbox1.text does not work  it says textbox 1 not declared how do I declare a referance to textbox1 in a form view


 
0
 
jfgrayiiiAuthor Commented:
I am using visual studio 2005 btw
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.