Pass VB Variable to ASP Control Property

  • Thread starter Thread starter Robert Bevington
  • Start date Start date
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
 
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... :-)
 
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
 
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.
 
Back
Top