473,388 Members | 1,340 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How do I Declare a text box

Mo
Hi,

I am trying to grab the text value of a text box in a formview. I know
how to do it the long way using findcontrol but I have a few textboxes
in the control and I am looking for a one liner to grab this value. I
am looking for something like this code:

string[] MyArray = new string[10];
MyArray[0] = (TextBox)FormView6.FindControl("FirstTextBox").Tex t;

But obviously this is not the right format to declare it! Any body have
an idea how to declare this value?

Thanks,
Mo

Jan 23 '07 #1
3 3967
Ok Google just moved their beta to live and it isn't working in Opera,
so as I'm typing blind, bear with me :)

I think

MyArray[0] =(TextBox)(FormView6.FindControl("FirstTextBox")). Text;

should work, you need to cast the entire expression that refers to the
textbox.
On 23 Jan, 23:00, "Mo" <le_mo...@yahoo.comwrote:
Hi,

I am trying to grab the text value of a text box in a formview. I know
how to do it the long way using findcontrol but I have a few textboxes
in the control and I am looking for a one liner to grab this value. I
am looking for something like this code:

string[] MyArray = new string[10];
MyArray[0] = (TextBox)FormView6.FindControl("FirstTextBox").Tex t;

But obviously this is not the right format to declare it! Any body have
an idea how to declare this value?

Thanks,
Mo
Jan 24 '07 #2
"DeveloperX" <nn*****@operamail.comwrote in message
news:11*********************@q2g2000cwa.googlegrou ps.com...
MyArray[0] =(TextBox)(FormView6.FindControl("FirstTextBox")). Text;
Haven't you missed a bracket off...?

MyArray[0] = ((TextBox)(FormView6.FindControl("FirstTextBox")). Text;
Jan 24 '07 #3
Yep, sorry I was having browser issues (and probably morning brain
issues)

I meant:

MyArray[0] = ((TextBox)FormView6.FindControl("FirstTextBox")).T ext;

So FindControl refers to a method on FormView6 that returns a Control
but the reason it went wrong is because .Text refers to a property on a
TextBox. By enclosing the cast and the function in brackets we force
the order of evaluation.

This would also work

TextBox t = (TextBox)FormView6.FindControl("FirstTextBox")
MyArray[0] = t.Text;
On 24 Jan, 01:19, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"DeveloperX" <nntp...@operamail.comwrote in messagenews:11*********************@q2g2000cwa.goo glegroups.com...
MyArray[0] =(TextBox)(FormView6.FindControl("FirstTextBox")). Text;Haven't you missed a bracket off...?

MyArray[0] = ((TextBox)(FormView6.FindControl("FirstTextBox")). Text;
Jan 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Walti | last post by:
Hi I'm trying to interface a foreign DLL that is written in Delphi. I know: - Delphi-Integer is a 32-Bit signed Integer --> VB: LONG - Delphi-PChar is a Pointer to Zero-Terminated ASCII String...
15
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
4
by: Shapper | last post by:
Hello, I have a label as follows: <label id="lName" for="name">Name:<input type="text" id="name"></input></label> I need to declare the label in my page.aspx.vb so I can access it on page...
1
by: marfi95 | last post by:
I'm trying to call methods in a C++ dll from vb.net that is not a .com component. I've read I can just use regular Declare statements just as you do in VB6 except that some of the types need to...
23
by: mark.moore | last post by:
I know this has been asked before, but I just can't find the answer in the sea of hits... How do you forward declare a class that is *not* paramaterized, but is based on a template class? ...
2
by: juan.gautier | last post by:
Hi, I try to construct a SQL code for a view to select a specific data from a table, this query take the value of the filter from a text box in a visual basic 6.0 form. my problem is when i...
0
ADezii
by: ADezii | last post by:
The motivation for this Tip was a question asked by one of our Resident Experts, FishVal. The question was: How to Declare Default Method/Property in a Class Module? My response to the question was...
1
by: adz1809 | last post by:
I'm having a problem with updating a record through a form. Here is the error: Server Error in '/AccoEndUser' Application....
1
by: AnDiKa | last post by:
Dim DatTim1 As Date = #12/1/2007# Dim DatTim2 As Date = #12/1/2007# Dim WD As Long = DateDiff(DateInterval.Day, DatTim1, DatTim2) Me.totalCount.Text = WD + 1 I used the code above to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.