By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,564 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,564 IT Pros & Developers. It's quick & easy.

Writing Session Variable Information To a Table

P: n/a
I have a four page form. Pages 1-3 stores there information in a session
variables. Page four is reached (a final review page) and then the
information will be written to the SQL server.

When I tried to enter some code in the HTML table by hand so I could get it
to show up in the right place. For example I use this code in the HTML
table:

<td><%=sessionvar1%><%=sessionvar2%></td>

Compile and run, when I get to the 4th page it says that sessionvar1 has not
been declared. Can I use session variables this way to display the
information?
Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Justin, thanks for your reply.

I tried doing that way. The only problem doing it this way is this
information is coming from a series of check boxes on the first page. So it
will vary the amount of information that will be displayed on the summary
page. If I put all these label fields in that cell of the table, it will
space it out and leave a huge gap. What I was looking to for was something
that would allow the cell to conform to the amount of information that will
be presented.

Thanks again.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
Michelle,

No, that isn't the proper way to use them.

I would put a label into the table and then when you get to the page set the text of the label = to the session variable.

(e.g.

Label1.Text = CType(Session("var1"), String)

)

Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Michelle A." <me@me.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
I have a four page form. Pages 1-3 stores there information in a session variables. Page four is reached (a final review page) and then the
information will be written to the SQL server.

When I tried to enter some code in the HTML table by hand so I could get

it
to show up in the right place. For example I use this code in the HTML
table:

<td><%=sessionvar1%><%=sessionvar2%></td>

Compile and run, when I get to the 4th page it says that sessionvar1 has

not
been declared. Can I use session variables this way to display the
information?


Nov 17 '05 #2

P: n/a
concatenate
"Michelle A." <me@me.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Justin, thanks for your reply.

I tried doing that way. The only problem doing it this way is this
information is coming from a series of check boxes on the first page. So it will vary the amount of information that will be displayed on the summary
page. If I put all these label fields in that cell of the table, it will
space it out and leave a huge gap. What I was looking to for was something that would allow the cell to conform to the amount of information that will be presented.

Thanks again.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
Michelle,

No, that isn't the proper way to use them.

I would put a label into the table and then when you get to the page set

the
text of the label = to the session variable.

(e.g.

Label1.Text = CType(Session("var1"), String)

)

Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Michelle A." <me@me.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
I have a four page form. Pages 1-3 stores there information in a session variables. Page four is reached (a final review page) and then the
information will be written to the SQL server.

When I tried to enter some code in the HTML table by hand so I could get
it
to show up in the right place. For example I use this code in the
HTML table:

<td><%=sessionvar1%><%=sessionvar2%></td>

Compile and run, when I get to the 4th page it says that sessionvar1

has not
been declared. Can I use session variables this way to display the
information?



Nov 17 '05 #3

P: n/a
Let me add some code:

Here is the code behind page: (I know this might not be the most efficent
way )

An if statement checks what check boxes were checked and displays them to
the correct label in the table:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("Gifttoag") Then
Me.Label1.Text = "College of Agriculture"
Else
Me.Label1.Text = ""
End If
If Session("Gifttobus") Then
Me.Label2.Text = "College of Buisness "
Else
Me.Label2.Text = ""
End If
If Session("Gifttodesign") Then
Me.Label3.Text = "College of Design"
Else
Me.Label3.Text = ""
End If
If Session("Gifttoedu") Then
Me.Label4.Text = "College of Education"
Else
Me.Label4.Text = ""
End If
If Session("Gifttoengin") Then
Me.Label5.Text = "College of Engineering"
Else
Me.Label5.Text = ""
End If
If Session("Gifttofcs") Then
Me.Label6.Text = "College of Family and Consumer Sciences"
Else
Me.Label6.Text = ""
End If
If Session("Gifttolas") Then
Me.Label7.Text = "College of Liberal Arts and Sciences"
Else
Me.Label7.Text = ""
End If
If Session("Gifttovetmed") Then
Me.Label8.Text = "College of Veterinary Medicine"
Else
Me.Label8.Text = ""
End If
If Session("Gifttolibrary") Then
Me.Label9.Text = "University Library"
Else
Me.Label9.Text = ""
End If
If Session("Gifttomorrill") Then
Me.Label10().Text = "Morrill Hall Restoration Project"
Else
Me.Label10.Text = ""
End If
If Session("Gifttoarea") Then
Me.Label11().Text = "Area of Greatest Need"
Else
Me.Label11.Text = ""
End If

Me.Label12.Text = Session("Gifttoother")
Me.Label13.Text = Session("GiftAmount")
End Sub
Here is the HTML section where the information is displayed in the table.

<tr>
<td style="WIDTH: 268px; HEIGHT: 21px" align="left">Gift
Desgination(s):</td>
<td align="center" style="HEIGHT: 21px">

<asp:Label id="Label1" runat="server">Label</asp:Label>

<asp:label id="Label2" runat="server">Label</asp:label>
<asp:label id="Label3" runat="server">Label</asp:label>
<asp:label id="Label4" runat="server">Label</asp:label>
<asp:label id="Label5" runat="server">Label</asp:label>
<asp:label id="Label6" runat="server">Label</asp:label>
<asp:label id="Label7" runat="server">Label</asp:label>
<asp:label id="Label8" runat="server">Label</asp:label>
<asp:Label id="Label9" runat="server">Label</asp:Label>
<asp:Label id="Label10" runat="server">Label</asp:Label>
<asp:Label id="Label11" runat="server">Label</asp:Label>
<asp:Label id="Label12" runat="server">Label</asp:Label>
</td>
</tr>

"Michelle A." <me@me.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Would I add that in the HTML code or in the Code behind pages..?
"Jason (MFT1)" <us****@newsgroup.pls> wrote in message
news:eQ****************@TK2MSFTNGP09.phx.gbl...
concatenate
"Michelle A." <me@me.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Justin, thanks for your reply.

I tried doing that way. The only problem doing it this way is this
information is coming from a series of check boxes on the first page. So
it
will vary the amount of information that will be displayed on the summary page. If I put all these label fields in that cell of the table, it will space it out and leave a huge gap. What I was looking to for was

something
that would allow the cell to conform to the amount of information that

will
be presented.

Thanks again.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
> Michelle,
>
> No, that isn't the proper way to use them.
>
> I would put a label into the table and then when you get to the page set the
> text of the label = to the session variable.
>
> (e.g.
>
> Label1.Text = CType(Session("var1"), String)
>
> )
>
> Sincerely,
>
>
> --
> S. Justin Gengo, MCP
> Web Developer
>
> Free code library at:
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzche
>
>
> "Michelle A." <me@me.com> wrote in message
> news:uF**************@TK2MSFTNGP12.phx.gbl...
> > I have a four page form. Pages 1-3 stores there information in a
session
> > variables. Page four is reached (a final review page) and then the > > information will be written to the SQL server.
> >
> > When I tried to enter some code in the HTML table by hand so I could get
> it
> > to show up in the right place. For example I use this code in the

HTML
> > table:
> >
> > <td><%=sessionvar1%><%=sessionvar2%></td>
> >
> > Compile and run, when I get to the 4th page it says that
sessionvar1 has
> not
> > been declared. Can I use session variables this way to display

the > > information?
> >
> >
>
>



Nov 17 '05 #4

P: n/a
I usually use the code behind but it doesn't make much difference I don't
suppose. I also use a delimiter which makes it easier to use the resultant
string later.

HTH
"Michelle A." <me@me.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Would I add that in the HTML code or in the Code behind pages..?
"Jason (MFT1)" <us****@newsgroup.pls> wrote in message
news:eQ****************@TK2MSFTNGP09.phx.gbl...
concatenate
"Michelle A." <me@me.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Justin, thanks for your reply.

I tried doing that way. The only problem doing it this way is this
information is coming from a series of check boxes on the first page. So
it
will vary the amount of information that will be displayed on the summary page. If I put all these label fields in that cell of the table, it will space it out and leave a huge gap. What I was looking to for was

something
that would allow the cell to conform to the amount of information that

will
be presented.

Thanks again.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
> Michelle,
>
> No, that isn't the proper way to use them.
>
> I would put a label into the table and then when you get to the page set the
> text of the label = to the session variable.
>
> (e.g.
>
> Label1.Text = CType(Session("var1"), String)
>
> )
>
> Sincerely,
>
>
> --
> S. Justin Gengo, MCP
> Web Developer
>
> Free code library at:
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzche
>
>
> "Michelle A." <me@me.com> wrote in message
> news:uF**************@TK2MSFTNGP12.phx.gbl...
> > I have a four page form. Pages 1-3 stores there information in a
session
> > variables. Page four is reached (a final review page) and then the > > information will be written to the SQL server.
> >
> > When I tried to enter some code in the HTML table by hand so I could get
> it
> > to show up in the right place. For example I use this code in the

HTML
> > table:
> >
> > <td><%=sessionvar1%><%=sessionvar2%></td>
> >
> > Compile and run, when I get to the 4th page it says that
sessionvar1 has
> not
> > been declared. Can I use session variables this way to display

the > > information?
> >
> >
>
>



Nov 17 '05 #5

P: n/a
Michelle,

I understand you don't know how many checkboxes values will need to be
displayed.

Do you know how to add labels to a control dynamically? I think this would
be the best solution.

Put a placeholder control in the table cell. Then dynamically create a label
for every check box that's checked and then add that label to the
placeholder.

'---Sample Code

If Session("Gifttoag") Then
Call AddLabel("College of Agriculture")
End If

If Session("Gifttobus") Then
Call AddLabel("College of Buisness ")
End If

If Session("Gifttodesign") Then
Call AddLabel("College of Design")
End If

'---This subroutine adds a label to the placeholder
Private Sub AddLabel(ByVal textToAdd As String)
Dim Label As New Label
Label.Text = textToAdd
Placeholder1.Controls.Add(Label)

Dim Literal As New LiteralControl
Literal.Text = "<br>"
Placeholder1.Controls.Add(Literal)
End Sub
Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Michelle A." <me@me.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Let me add some code:

Here is the code behind page: (I know this might not be the most efficent
way )

An if statement checks what check boxes were checked and displays them to
the correct label in the table:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("Gifttoag") Then
Me.Label1.Text = "College of Agriculture"
Else
Me.Label1.Text = ""
End If
If Session("Gifttobus") Then
Me.Label2.Text = "College of Buisness "
Else
Me.Label2.Text = ""
End If
If Session("Gifttodesign") Then
Me.Label3.Text = "College of Design"
Else
Me.Label3.Text = ""
End If
If Session("Gifttoedu") Then
Me.Label4.Text = "College of Education"
Else
Me.Label4.Text = ""
End If
If Session("Gifttoengin") Then
Me.Label5.Text = "College of Engineering"
Else
Me.Label5.Text = ""
End If
If Session("Gifttofcs") Then
Me.Label6.Text = "College of Family and Consumer Sciences"
Else
Me.Label6.Text = ""
End If
If Session("Gifttolas") Then
Me.Label7.Text = "College of Liberal Arts and Sciences"
Else
Me.Label7.Text = ""
End If
If Session("Gifttovetmed") Then
Me.Label8.Text = "College of Veterinary Medicine"
Else
Me.Label8.Text = ""
End If
If Session("Gifttolibrary") Then
Me.Label9.Text = "University Library"
Else
Me.Label9.Text = ""
End If
If Session("Gifttomorrill") Then
Me.Label10().Text = "Morrill Hall Restoration Project"
Else
Me.Label10.Text = ""
End If
If Session("Gifttoarea") Then
Me.Label11().Text = "Area of Greatest Need"
Else
Me.Label11.Text = ""
End If

Me.Label12.Text = Session("Gifttoother")
Me.Label13.Text = Session("GiftAmount")
End Sub
Here is the HTML section where the information is displayed in the table.

<tr>
<td style="WIDTH: 268px; HEIGHT: 21px" align="left">Gift
Desgination(s):</td>
<td align="center" style="HEIGHT: 21px">

<asp:Label id="Label1" runat="server">Label</asp:Label>

<asp:label id="Label2" runat="server">Label</asp:label>
<asp:label id="Label3" runat="server">Label</asp:label>
<asp:label id="Label4" runat="server">Label</asp:label>
<asp:label id="Label5" runat="server">Label</asp:label>
<asp:label id="Label6" runat="server">Label</asp:label>
<asp:label id="Label7" runat="server">Label</asp:label>
<asp:label id="Label8" runat="server">Label</asp:label>
<asp:Label id="Label9" runat="server">Label</asp:Label>
<asp:Label id="Label10" runat="server">Label</asp:Label>
<asp:Label id="Label11" runat="server">Label</asp:Label>
<asp:Label id="Label12" runat="server">Label</asp:Label>
</td>
</tr>

"Michelle A." <me@me.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Would I add that in the HTML code or in the Code behind pages..?
"Jason (MFT1)" <us****@newsgroup.pls> wrote in message
news:eQ****************@TK2MSFTNGP09.phx.gbl...
concatenate
"Michelle A." <me@me.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> Justin, thanks for your reply.
>
> I tried doing that way. The only problem doing it this way is this
> information is coming from a series of check boxes on the first page.
So
it
> will vary the amount of information that will be displayed on the

summary
> page. If I put all these label fields in that cell of the table, it

will
> space it out and leave a huge gap. What I was looking to for was
something
> that would allow the cell to conform to the amount of information
that will
> be presented.
>
> Thanks again.
>
>
> "S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
> news:uh**************@tk2msftngp13.phx.gbl...
> > Michelle,
> >
> > No, that isn't the proper way to use them.
> >
> > I would put a label into the table and then when you get to the page
set
> the
> > text of the label = to the session variable.
> >
> > (e.g.
> >
> > Label1.Text = CType(Session("var1"), String)
> >
> > )
> >
> > Sincerely,
> >
> >
> > --
> > S. Justin Gengo, MCP
> > Web Developer
> >
> > Free code library at:
> > www.aboutfortunate.com
> >
> > "Out of chaos comes order."
> > Nietzche
> >
> >
> > "Michelle A." <me@me.com> wrote in message
> > news:uF**************@TK2MSFTNGP12.phx.gbl...
> > > I have a four page form. Pages 1-3 stores there information in

a > session
> > > variables. Page four is reached (a final review page) and then

the > > > information will be written to the SQL server.
> > >
> > > When I tried to enter some code in the HTML table by hand so I could get
> > it
> > > to show up in the right place. For example I use this code in the HTML
> > > table:
> > >
> > > <td><%=sessionvar1%><%=sessionvar2%></td>
> > >
> > > Compile and run, when I get to the 4th page it says that sessionvar1 has
> > not
> > > been declared. Can I use session variables this way to display the > > > information?
> > >
> > >
> >
> >
>
>



Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.