Pass VB Variable to ASP Control Property

R

Robert Bevington

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
 
M

Mark Rae [MVP]

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%>"?

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

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

Robert Bevington

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
 
M

Mark Rae [MVP]

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?

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.
 

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

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top