Newbie variable question

C

charan1976

Hello,
I'm an asp.net newbie trying to convert some ASP code into ASP.Net.
Here's what I'm trying to do. I have a variable called "orderNo" which
I'm declaring as below in the Page_Load sub:
=========================
Sub Page_Load
if Not Page.Ispostback then
dim orderNo
orderNo = Request.QueryString("orderNo")
end if
End Sub
=========================
Then I'm trying to display the value in a table header:
=========================
<form runat="server">
<asp:Table Runat="server" ID="tblJnl">
<asp:TableRow>
<asp:TableHeaderCell>Order No.: '<%#orderNo%>' </asp:TableHeaderCell>
</asp:TableRow>
</form>
=========================

This gives me the compilation error.
=========================
Compiler Error Message: BC30451: Name 'orderNo' is not declared.

d:\inetpub\wwwroot\PickTicket.aspx(42) : error BC30451: Name 'orderNo'
is not declared.
target.SetDataBoundString(0, System.Convert.ToString(orderNo))
~~~~~~~
=========================

Can anyone please point me to what I'm doing wrong here? I'm sure it's
something simple that I'm missing.
Thanks in advance
 
A

Angel J. Hernández M.

Make it a class member (public) instead of a variable. The compiler can't
find the variable 'cause it goes outta scope when the load method exits.
For example:
public orderNo as Integer

Regards,
 

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

Top