accessing a code-behind variable from a user control

T

TB

On a user control (ascx) I have a datagrid with a hyperlink column
containing the following code:

<asp:HyperLinkcolumn headerstyle-width="80px" ItemStyle-Width="80px"
DataNavigateUrlField="ID" DataNavigateUrlFormatString="home.aspx?
i={0}&amp;<%=lang%>"
Text="Click"></asp:HyperLinkcolumn>

However when I run the page containing the user control, the resulting
link in the column litterally contains ";<%=lang%>" and not the lang
variable that I want to call.

What I am doing wrong here?

Thanks

TB
 
G

Guest

In one of my pages I construct the NavigateUrlFormatString during page Load
event where I insert the variable value into the link format.

Not sure whether you can achieve it using declarative syntax ...
 
T

TB

I could do the whole datagrid programmatically, but in this case I
prefer it the "old way".

Could the problem be caused by an accidental combination of characters
(double quotation marks, etc), which could avoided by way of using
HTML equivalents (&quot;, &amp;, etc)?

TB
 
G

Guest

Not sure whether this is any cleaner, but another way could be to add one
more column to the grid's datasource which value would be set to your code
behind variable (you can even vary it from row to row) and then inside the
grid's column:

DataNavigateUrlFields="MyIdFieldName,MyCodeBehindCalculatedFieldName"
DataNavigateUrlFormatString="home.aspx?i={0}&{1}"
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top