Thanks for your followup Tdar,
From the code snippet you provided, I think the problem is caused by the
following line:
Label lbldesc = FormView1.Row.FindControl("heightLabel") as string
Label lbldesc
is the variable declaration style in C#, also there is no "as" in VB.NET.
in VB.NET, we should use
dim lbldesc as Label
lbldesc = FormView1.Row.FindControl("heightLabel")
if you feel necessary, you can also do a explicit cast like:
lbldesc = CType(Label, FormView1.Row.FindControl("heightLabel"))
Hope helps. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
--------------------
| Thread-Topic: formview control question
| thread-index: AcXMF4+WJb7S9lZTSFujx5IamwNZrg==
| X-WBNR-Posting-Host: 24.73.223.27
| From: "=?Utf-8?B?VGRhclRkYXI=?=" <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
<
[email protected]>
<p#
[email protected]>
| Subject: RE: formview control question
| Date: Sat, 8 Oct 2005 07:50:01 -0700
| Lines: 244
| Message-ID: <
[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:11229
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| This is helpfull, however,
|
|
|
| Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
| System.EventArgs) Handles Button1.Click
| Dim output As String
| Label lbldesc = FormView1.Row.FindControl("heightLabel") as string
| output = lbldesc.text
| MsgBox(output)
| End Sub
|
|
| When i use the "label" as the first word it:
| Error 9 'label' is a type and cannot be used as an expression.
|
| If i do :
|
| Dim output As String, lblid
| lblid = FormView1.Row.FindControl("lengthLabel")
| output = lblid.text
| MsgBox(output)
|
| not sure what TYpe it is looking for I try string and i get value of type
| 'system.web.ui.control cannot be converted to string.
| I tried array as thing
|
|
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Thanks for your response Tdar,
| >
| > Here is a simple example demonstrate the things I mentioend earlier.
| > Suppose we have the following FormView and ItemTemplate defined:
| >
| > <asp:FormView id="FormView1" ....>
| > .........
| >
| > <ItemTemplate>
| > CategoryID:
| > <asp:Label ID="CategoryIDLabel" runat="server"
Text='<%#
| > Eval("CategoryID") %>'>
| > </asp:Label><br />
| > CategoryName:
| > <asp:Label ID="CategoryNameLabel" runat="server"
Text='<%#
| > Bind("CategoryName") %>'>
| > </asp:Label><br />
| > Description:
| > <asp:Label ID="DescriptionLabel" runat="server"
Text='<%#
| > Bind("Description") %>'>
| > </asp:Label><br />
| > </ItemTemplate>
| >
| > </asp:FormView>
| >
| > So when we want to retrieve the binded data in the current displayed
| > record(in normal mode), we can use the following code to find those
Label
| > controls' reference and access their text propety.
| >
| >
| > protected void Button1_Click(object sender, EventArgs e)
| > {
| > Label lblID = FormView1.Row.FindControl("CategoryIDLabel") as Label;
| > Label lblName = FormView1.Row.FindControl("CategoryNameLabel") as
Label;
| > Label lblDesc = FormView1.Row.FindControl("DescriptionLabel") as
Label;
| >
| > Response.Write("<br>CategoryID: " + lblID.Text);
| > Response.Write("<br>CategoryName: " + lblName.Text);
| > Response.Write("<br>Description: " + lblDesc.Text);
| > }
| >
| > Also, if you use TextBox instead, just change the control type to
TextBox.
| > And as I've also mentioned, we can only access the controls which is in
the
| > active template (ItemTemplate, EditTemplate , InsertTemplate ....).
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure!
www.microsoft.com/security
| >
| >
| > --------------------
| > | Thread-Topic: formview control question
| > | thread-index: AcXKhw7stEqxcoBPTcaCiJA3aOg3Dw==
| > | X-WBNR-Posting-Host: 24.73.223.27
| > | From: "=?Utf-8?B?VGRhclRkYXI=?=" <
[email protected]>
| > | References: <
[email protected]>
| > <
[email protected]>
| > | Subject: RE: formview control question
| > | Date: Thu, 6 Oct 2005 08:03:06 -0700
| > | Lines: 123
| > | Message-ID: <
[email protected]>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:11198
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > |
| > | So what are you saying here that I would use something like
| > | Girth = FormView1.Row.FindControl("LEGNTHTEXTBOX") +
| > | FormView1.Row.FindControl("WIDTHTEXTBOX")
| > |
| > | but how do i get the .text value of what the user entered in
| > | and i was using that FormView1_PageIndexChanging to triger the
| > | procedure and had default value of 0.
| > |
| > | I guess i am tring do something that is not possiable, I am VERY new
| > | to asp.net in general I have a Goal of just using and working within
your
| > | controls to speed up development.
| > |
| > | I have been watching the training on ASP.net 2.0 and just have not
run
| > acrosed
| > | this i guess more advanced information.
| > |
| > | Frankly i have not seen any training on how to modify the contants of
a
| > | form/details view in respects to say making one field a drop down
select
| > | from a data connection for a inserting or updating a data record, I
still
| > | find myself having to make a from for that granted I am sure that is
jsut
| > | drag in a field also but then having to do that it makes the use of
your
| > new
| > | facny controls somewhat limited.
| > | So if there is something written up or a video show on eather of
these
| > | subjects please point me in the right direction also if you could
please
| > | provide an example of what i am asking for re the lenght width it
would
| > be
| > | helpfull i learn much faster by seeing how it is done ....
| > |
| > |
| > |
| > |
| > |
| > | "Steven Cheng[MSFT]" wrote:
| > |
| > | > Hi Tdar ,
| > | >
| > | > Thanks for your posting.
| > | > regarding on this issue, I've also noticed your another thread in
the
| > | >
| > | > Subject: RE: asp.net 2.0 beta2 and formview
| > | > Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | >
| > | > I've posted my response there. As mentioned in that message, when
we
| > define
| > | > some inner controls in the
| > | > formview's template, we can access them through the
| > | >
| > | > FormView.Row.FindControl( controlID)
| > | >
| > | > controlID is the ID of the control you defined in the formView's
| > certain
| > | > template. Also, we can only retrieve control instance in a certain
| > template
| > | > when the template is in active. In other word, in normal mode, we
can
| > | > access controls in ItemTemplate through
| > | > FormView.Row.FindControl( controlID)
| > | >
| > | > and only in Edit mode can we access controls in Edit template.
| > | >
| > | > Hope helps. Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure!
www.microsoft.com/security
| > | >
| > | >
| > | > --------------------
| > | > | Thread-Topic: formview control question
| > | > | thread-index: AcXKLyzepemS1lAGQN6bchXeDwgm3A==
| > | > | X-WBNR-Posting-Host: 65.35.95.11
| > | > | From: "=?Utf-8?B?VGRhclRkYXI=?=" <
[email protected]>
| > | > | Subject: formview control question
| > | > | Date: Wed, 5 Oct 2005 21:34:01 -0700
| > | > | Lines: 33
| > | > | Message-ID: <
[email protected]>
| > | > | MIME-Version: 1.0
| > | > | Content-Type: text/plain;
| > | > | charset="Utf-8"
| > | > | Content-Transfer-Encoding: 7bit
| > | > | X-Newsreader: Microsoft CDO for Windows 2000
| > | > | Content-Class: urn:content-classes:message
| > | > | Importance: normal
| > | > | Priority: normal
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | > | Xref: TK2MSFTNGXA01.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet.webcontrols:11186
| > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | > |
| > | > | I have a form view control linked to a sql database
| > | > | with the database fields of:
| > | > |
| > | > | lenght
| > | > | weidth
| > | > | height
| > | > | oversize
| > | > |
| > | > | I would like to access the lenght after user types in values to
| > | > | run some math to determine what oversize shoud be and enter
| > | > | that in automatically before the fromview insert is clicked
| > | > |
| > | > | However since i am new to working with these controls not sure
what
| > | > | to do.
| > | > |
| > | > | In the past it would be like:
| > | > |