Forum Moderators: open

Message Too Old, No Replies

I can show the dynamic text

But I can't use it as a variable (c#)

         

Argblat

7:09 pm on Jul 13, 2005 (gmt 0)

10+ Year Member



Hi all, I'm going to try to keep this as general as possible so that somebody actually wants to help me :) (please do)...that being said, here goes.

I'm using Dreamweaver to create a lot of my asp.net (c#) code.

Pulling from a DataSet, the following dynamic text works perfectly fine, displaying in my pages:

<%# DSPOC.FieldValue("DYNTEXT", Container) %>

However, if I try to use this within an function or other code structure it gives me an error.

Now here's the workaround that doesn't make any sense to me. If I then add the following hidden text field to my code:

<asp:textbox id="dynText" text='<%# DSPOC.FieldValue("DYNTEXT", Container) %>' TextMode="SingleLine" Columns="20" runat="server" Visible="false" />

Then I can do the following

objEmail.Body += "Dynamic Text: " + dynText.Text;

Now it seems painfully obvious to me that I'm hacking this all up and adding 2 extra steps. Can someone please explain to this asp.net/c# amateur what he can do to more elegantly solve this dilemna?

MUCHOS gracis!
-mike

TheNige

2:40 am on Jul 14, 2005 (gmt 0)

10+ Year Member



I am assuming that you are pulling DSPOC.FieldValue("DYNTEXT", Container) from a dataset or something for a grid using a databind? If so, then the way you are doing it is the only way when using a databind.

You would need to access the dataset directly in your code behind to manipulate it directly.

The databind just runs through the datasource to create your grids or what have you.

aajiz

9:18 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



I don't know about Dreamweaver because I code directly in C#/VB.Net using Visual Studio.NET. I would suggest do the following:

In the Page_Load event, check IsPostBack property and then add something along the lines of:

dynText.Text = DSPOC.FieldValue("DYNTEXT", null);