Saturday, March 24, 2012

Pass VB Variable to ASP Control Property

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"Robert Bevington" <rbevington@.freenet.de> wrote in message
news:u8YBYzLxHHA.4612@.TK2MSFTNGP04.phx.gbl...

> 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... :-)
Mark Rae
ASP.NET MVP
http://www.markrae.net
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 enthlt 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:
> "Robert Bevington" <rbevington@.freenet.de> wrote in message
> news:u8YBYzLxHHA.4612@.TK2MSFTNGP04.phx.gbl...
>
> Looks OK to me - what error(s) are you getting...?
> Also, I'm assuming that VBVariable *does* actually contain a value... :-)
>
"Robert Bevington" <rbevington@.freenet.de> wrote in message
news:%23zKYDJMxHHA.3652@.TK2MSFTNGP04.phx.gbl...

> 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 enthlt 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.
Mark Rae
ASP.NET MVP
http://www.markrae.net

0 comments:

Post a Comment