Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Pass VB Variable to ASP Control Property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Bevington - 12 Jul 2007 20:42 GMT
Hi everyone,

this must be easy, but I can't get it right.

How do I pass the VBvariable created at page_load to the property of a
web control:

....
<asp:DropDownList ID="cbo1" runat="server" DataSourceID="SqlDataSource1"
            DataTextField="<%=VBVariable%>"
....

What is the correct syntax for DataTextField="<%=VBVariable%>"?

Best regards

Robert
Mark Rae [MVP] - 12 Jul 2007 21:05 GMT
> Hi everyone,
>
[quoted text clipped - 9 lines]
>
> What is the correct syntax for DataTextField="<%=VBVariable%>"?

Looks OK to me - what error(s) are you getting...?

Also, I'm assuming that VBVariable *does* actually contain a value... :-)

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Robert Bevington - 12 Jul 2007 21:21 GMT
Hi Mark,

If I hard code the variable everything works fine. If Then replace the
text "ATT_Department" with "<%=VBVariable%>", I got the following message:

DataBinding: System.Data.DataRowView enthält keine Eigenschaft mit dem
Namen <%=ATT_Name %>.

Translated to English: DataBinding: System.Data.DataRowView has no
property named <%=ATT_Name %>

In Debug mode, if I place the mouse over the variable it reads
"ATT_Department". So it does have a value.

Any ideas?

Rob

Mark Rae [MVP] schrieb:

>> Hi everyone,
>>
[quoted text clipped - 13 lines]
>
> Also, I'm assuming that VBVariable *does* actually contain a value... :-)
Mark Rae [MVP] - 12 Jul 2007 21:56 GMT
> If I hard code the variable everything works fine. If Then replace the
> text "ATT_Department" with "<%=VBVariable%>", I got the following message:
[quoted text clipped - 9 lines]
>
> Any ideas?

How are you declaring the server-side variable? In order to visible to the
aspx page, server-side variables need to be Public or Protected.

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.