formview control question

T

TdarTdar

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:

oversize.text = lenght.text + width.text

so in recap:

formview control linked to database

fields:
lenght: 21 < - user types in
width: 11 < - user types in
oversize: 32 <- computer does math and enters

THEN user submits the form view to enter data into database.
 
S

Steven Cheng[MSFT]

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:
|
| oversize.text = lenght.text + width.text
|
| so in recap:
|
| formview control linked to database
|
| fields:
| lenght: 21 < - user types in
| width: 11 < - user types in
| oversize: 32 <- computer does math and enters
|
| THEN user submits the form view to enter data into database.
|
|
|
|
|
 
T

TdarTdar

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 ....
 
S

Steven Cheng[MSFT]

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:
| > |
| > | oversize.text = lenght.text + width.text
| > |
| > | so in recap:
| > |
| > | formview control linked to database
| > |
| > | fields:
| > | lenght: 21 < - user types in
| > | width: 11 < - user types in
| > | oversize: 32 <- computer does math and enters
| > |
| > | THEN user submits the form view to enter data into database.
| > |
| > |
| > |
| > |
| > |
| >
| >
|
 
T

TdarTdar

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 said:
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:
| > |
| > | oversize.text = lenght.text + width.text
| > |
| > | so in recap:
| > |
| > | formview control linked to database
| > |
| > | fields:
| > | lenght: 21 < - user types in
| > | width: 11 < - user types in
| > | oversize: 32 <- computer does math and enters
| > |
| > | THEN user submits the form view to enter data into database.
| > |
| > |
| > |
| > |
| > |
| >
| >
|
 
S

Steven Cheng[MSFT]

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:
| > | > |
| > | > | oversize.text = lenght.text + width.text
| > | > |
| > | > | so in recap:
| > | > |
| > | > | formview control linked to database
| > | > |
| > | > | fields:
| > | > | lenght: 21 < - user types in
| > | > | width: 11 < - user types in
| > | > | oversize: 32 <- computer does math and enters
| > | > |
| > | > | THEN user submits the form view to enter data into database.
| > | > |
| > | > |
| > | > |
| > | > |
| > | > |
| > | >
| > | >
| > |
| >
| >
|
 
T

TdarTdar

Hi thanks for bearing with me, here is what i get now :(

Dim lbldesc As Label, output As String
lbldesc = FormView1.Row.FindControl("heightLabel")
output = lbldesc.Text
MsgBox(output)
error:
Implicit conversion from 'System.Web.UI.Control' to
'System.Web.UI.WebControls.Label'.

or if i use

lbldesc = CType(Label, FormView1.Row.FindControl("heightLabel"))

error:
Array bounds cannot appear in type specifiers.
'Label' is a type and cannot be used as an expression.
Type 'FormView1.Row.FindControl' is not defined.


Thanks again for the help

David



Steven Cheng said:
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:
| > | > |
 
S

Steven Cheng[MSFT]

Hi David,

Thanks for your further response.
I'm surprised that you can not implicitly convert the Label instance
directly through object reference since it works well on myside. And for
your seconed statement, you should switch the two parameters (the first
parameter of "CType", should be the object instance, and the second should
be the Type name). Here is the code worked on my side:

Dim lbl As Label

'this is the implicit cast
'lbl = FormView1.Row.FindControl("CategoryNameLabel")

'explicit cast
lbl = CType(FormView1.Row.FindControl("CategoryNameLabel"), Label)

If Not lbl Is Nothing Then
Response.Write("<br>CategoryName: " + lbl.Text)
End If


Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
 
T

TdarTdar

CType(FormView1.Row.FindControl("CategoryNameLabel"), Label)

That also did the Trick, Thanks for hanging in with me...

David
 
T

TdarTdar

Ugh sorry one more,
How do i fill a value back into your controls:

FormView1.Row.FindControl("CategoryNameLabel") .text = "Whatever"

that does not seem to be right, unless it is because i am in beta 2 ???

David
 
S

Steven Cheng[MSFT]

Hi David,

Thanks for your further followup.
For my test, I also used a beta2 environment of the .NET 2.0/VS.NET 2005.
Anyway, I think it should be a environment specific problem since VB.NET
should by default support late binding accessing object members. Currently
you can still try using explicit casting first before access control member
like:

dim lbl as Label

lbl = CType(FormView1.Row.FindControl("CategoryNameLabel"), Label)

lbl.Text = xxxxx

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security




--------------------
| Thread-Topic: formview control question
| thread-index: AcXOgm1Zab+AnxnYT2aHY3zbeVUZTQ==
| 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]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: RE: formview control question
| Date: Tue, 11 Oct 2005 09:40:02 -0700
| Lines: 43
| 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: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:30573
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Ugh sorry one more,
| How do i fill a value back into your controls:
|
| FormView1.Row.FindControl("CategoryNameLabel") .text = "Whatever"
|
| that does not seem to be right, unless it is because i am in beta 2 ???
|
| David
|
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi David,
| >
| > Thanks for your further response.
| > I'm surprised that you can not implicitly convert the Label instance
| > directly through object reference since it works well on myside. And
for
| > your seconed statement, you should switch the two parameters (the first
| > parameter of "CType", should be the object instance, and the second
should
| > be the Type name). Here is the code worked on my side:
| >
| > Dim lbl As Label
| >
| > 'this is the implicit cast
| > 'lbl = FormView1.Row.FindControl("CategoryNameLabel")
| >
| > 'explicit cast
| > lbl = CType(FormView1.Row.FindControl("CategoryNameLabel"),
Label)
| >
| > If Not lbl Is Nothing Then
| > Response.Write("<br>CategoryName: " + lbl.Text)
| > End If
| >
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| >
| >
|
 
T

TdarTdar

Thanks,
Frankly there should be more detailed Training, If i had a video that
details all the ways to work with a control, I don't think we would have
had to go thru this. I really thanks you for your time, This is going to
help Big Time...



Steven Cheng said:
Hi David,

Thanks for your further followup.
For my test, I also used a beta2 environment of the .NET 2.0/VS.NET 2005.
Anyway, I think it should be a environment specific problem since VB.NET
should by default support late binding accessing object members. Currently
you can still try using explicit casting first before access control member
like:

dim lbl as Label

lbl = CType(FormView1.Row.FindControl("CategoryNameLabel"), Label)

lbl.Text = xxxxx

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security




--------------------
| Thread-Topic: formview control question
| thread-index: AcXOgm1Zab+AnxnYT2aHY3zbeVUZTQ==
| 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]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: RE: formview control question
| Date: Tue, 11 Oct 2005 09:40:02 -0700
| Lines: 43
| 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: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:30573
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Ugh sorry one more,
| How do i fill a value back into your controls:
|
| FormView1.Row.FindControl("CategoryNameLabel") .text = "Whatever"
|
| that does not seem to be right, unless it is because i am in beta 2 ???
|
| David
|
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi David,
| >
| > Thanks for your further response.
| > I'm surprised that you can not implicitly convert the Label instance
| > directly through object reference since it works well on myside. And
for
| > your seconed statement, you should switch the two parameters (the first
| > parameter of "CType", should be the object instance, and the second
should
| > be the Type name). Here is the code worked on my side:
| >
| > Dim lbl As Label
| >
| > 'this is the implicit cast
| > 'lbl = FormView1.Row.FindControl("CategoryNameLabel")
| >
| > 'explicit cast
| > lbl = CType(FormView1.Row.FindControl("CategoryNameLabel"),
Label)
| >
| > If Not lbl Is Nothing Then
| > Response.Write("<br>CategoryName: " + lbl.Text)
| > End If
| >
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| >
| >
|
 
S

Steven Cheng[MSFT]

You're welcome David,

BTW, if you have interest, you can have a look at the tutorial on the
beta.asp.net site which contains lots of samples there.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: formview control question
| thread-index: AcXPQCQNVDwpCSZqTqe/dyy7Wvi3JA==
| X-WBNR-Posting-Host: 65.35.95.11
| From: "=?Utf-8?B?VGRhclRkYXI=?=" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<p#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: RE: formview control question
| Date: Wed, 12 Oct 2005 08:18:03 -0700
| Lines: 117
| 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: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:30586
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Thanks,
| Frankly there should be more detailed Training, If i had a video that
| details all the ways to work with a control, I don't think we would have
| had to go thru this. I really thanks you for your time, This is going to
| help Big Time...
|
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi David,
| >
| > Thanks for your further followup.
| > For my test, I also used a beta2 environment of the .NET 2.0/VS.NET
2005.
| > Anyway, I think it should be a environment specific problem since
VB.NET
| > should by default support late binding accessing object members.
Currently
| > you can still try using explicit casting first before access control
member
| > like:
| >
| > dim lbl as Label
| >
| > lbl = CType(FormView1.Row.FindControl("CategoryNameLabel"), Label)
| >
| > lbl.Text = xxxxx
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| >
| >
| >
| >
| > --------------------
| > | Thread-Topic: formview control question
| > | thread-index: AcXOgm1Zab+AnxnYT2aHY3zbeVUZTQ==
| > | 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]>
| > <[email protected]>
| > <[email protected]>
| > <[email protected]>
| > <[email protected]>
| > | Subject: RE: formview control question
| > | Date: Tue, 11 Oct 2005 09:40:02 -0700
| > | Lines: 43
| > | 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: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:30573
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > |
| > | Ugh sorry one more,
| > | How do i fill a value back into your controls:
| > |
| > | FormView1.Row.FindControl("CategoryNameLabel") .text = "Whatever"
| > |
| > | that does not seem to be right, unless it is because i am in beta 2
???
| > |
| > | David
| > |
| > |
| > |
| > | "Steven Cheng[MSFT]" wrote:
| > |
| > | > Hi David,
| > | >
| > | > Thanks for your further response.
| > | > I'm surprised that you can not implicitly convert the Label
instance
| > | > directly through object reference since it works well on myside.
And
| > for
| > | > your seconed statement, you should switch the two parameters (the
first
| > | > parameter of "CType", should be the object instance, and the second
| > should
| > | > be the Type name). Here is the code worked on my side:
| > | >
| > | > Dim lbl As Label
| > | >
| > | > 'this is the implicit cast
| > | > 'lbl = FormView1.Row.FindControl("CategoryNameLabel")
| > | >
| > | > 'explicit cast
| > | > lbl = CType(FormView1.Row.FindControl("CategoryNameLabel"),
| > Label)
| > | >
| > | > If Not lbl Is Nothing Then
| > | > Response.Write("<br>CategoryName: " + lbl.Text)
| > | > End If
| > | >
| > | >
| > | > Hope helps. Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | >
| > | >
| > |
| >
| >
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Strange Problem with FormView Control 0
Populating a FormView from different data 1
Formview Question 5
Formview hijinks 1
FormView Insert 6
FormView Control 1
Uhhhhh, What can I do next? 6
Telegram bot api 0

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top