Solved

Displaying a variable

Posted on 2008-10-06
3
228 Views
Last Modified: 2013-12-17
I simple do not know how to display a variable on a page. The DAL approach I am using is code-behind TableAdapters.

I know how to use a TableAdapter and bind that to a repeater, table, etc. but I want to display a variable, possibly in a label, without using Design Mode, and without inline coding any sql statements.

Is it possible to accomplish this using the TableAdapter method, and do I have to assign some object the variable, or can I just display it in the presentation layer?
0
Comment
Question by:coldchillin
  • 2
3 Comments
 
LVL 4

Expert Comment

by:brene
ID: 22657326
If you have the variable in the code behind then follow this:
In the code behind (somewhere in the Page_Load):
string variableToDisplay = "I want this on the web page";
label1.Text = variableToDisplay;

In the aspx:
<asp:label id="label1" runat="server" Text="" />

Does that answer your question??
0
 
LVL 1

Author Comment

by:coldchillin
ID: 22661466
Using the tableadapter method, I have the following, which I am not able to make work:

azjobsiteTableAdapters.seekerProfileTableAdapter seeker = new azjobsiteTableAdapters.seekerProfileTableAdapter();
        Label1.Text = seeker.GetResumeViews(Convert.ToInt32(Session["rUserID"]));

My presentation layers looks like this:
<asp:Label ID="Label1" runat="server" Text="<%# DataBinder.Eval(Container.DataItem, "datePosted") %>"></asp:Label>

The error I get is that the server tag is not well formed.
0
 
LVL 4

Accepted Solution

by:
brene earned 500 total points
ID: 22664972
You need to use single quotes when calling some code eg.

<asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "datePosted") %>'></asp:Label>
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now