wtf am I doing wrong?

J

Joe Van Meer

Hi all,

I have a page that fills a dataset with 3 tables, relations are created and
now I am just simply trying to display the number of returned records from
one of the tables in the dataset and display that number on a label on my
webpage. I am having probs accomplishing this task to my surprise.

I have tested this value and am able to print it out at the top of my page
.... this is marked below with ***

The label problem is marked with **********



My code is below - entire page:


Thanks and cheers, Joe



<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1"
Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>


<script language="vb" runat="server">

SUB Page_Load(Sender As Object, E As EventArgs)

'SECURITY CHECKER
IF Session.Contents.Count = 0 THEN
response.redirect("logout.aspx")
END IF



Dim curAgentID as Integer
Dim curAgencyID as Integer
Dim curAgencyName as String
Dim curAgentName as String
Dim PageTitle as String
Dim curSecLevel as String
Dim curGroupID as Integer
Dim curStatus as String
Dim strSQLa as String
Dim strSQLb as String
Dim strSQLc as String
Dim ds as DataSet = New DataSet()
Dim mylabel as New Label


curAgentID = Session("sesempId")
curAgencyID = Session("sesempAgencyid")
curAgencyName = Session("sesempAgencyname")
PageTitle = "Agency Bookings"
curSecLevel = Session("sesempSecurity")
curGroupID = Session("sesempGroupid")



'AGENCY BOOKINGS QUERY
strSQLa = "SELECT bookingid, clientid, agencyid, empid, arn,
bookingdatetimestamp, status FROM BOOKING WHERE agencyid =" & curAgencyID &
" AND empid=" & curAgentID & " AND status = 'Draft'"
'CLIENT NAME QUERY
strSQLb = "SELECT clientid, fname, lname FROM CLIENT WHERE agencyid=" &
curAgencyID
'EMPLOYEE NAME QUERY
strSQLc = "SELECT empid, fname, lname FROM EMPLOYEE WHERE agencyid =" &
curAgencyID


'FILL BOOKINGS
Dim MyConn as New SQLConnection(ConfigurationSettings.AppSettings("dbConn"))
Dim myCmd as New SqlDataAdapter(strSQLa, MyConn)
myCmd.fill(ds, "BOOKING")

'FILL CLIENTS
Dim myCmdb as New SqlDataAdapter(strSQLb, MyConn)
myCmdb.fill(ds, "CLIENT")

'FILL EMPLOYEES
Dim myCmdc as New SqlDataAdapter(strSQLc, MyConn)
myCmdc.fill(ds, "EMPLOYEE")




*** THIS WORKS!!!!
'response.write (ds.Tables(0).Rows.Count)




'IF THERE ARENT ANY CLIENTS WITH BOOKINGS DO NOT DISPLAY !!!! SIMPLE MESSAGE
TO USER HERE STATING NO BOOKINGS IE: PANEL
IF ds.Tables(1).Rows.Count > 0 THEN

'SET UP TABLE RELATIONS HERE
Dim datrela as New DataRelation("ClientBookings",
ds.Tables("CLIENT").Columns("clientid"),
ds.Tables("BOOKING").Columns("clientid"))
'add relation to collection
ds.Relations.Add(datrela)


Dim datrelb as New DataRelation("EmployeeBookings",
ds.Tables("EMPLOYEE").Columns("empid"),
ds.Tables("BOOKING").Columns("empid"))
'add relation to collection
ds.Relations.Add(datrelb)


bookingspanel.visible = true
nobookingspanel.visible = false


'BIND DATA TO DATALIST
dlBookings.DataSource = ds
dlBookings.DataBind()
myConn.close


********* I GET A NOT DECLARED ERROR HERE on MYLABEL
mylabel.visible = true
mylabel.Text = ds.Tables(0).Rows.Count


ELSE


'SET LABEL MESSAGE HERE - NO BOOKINGS CURRENTLY, ETC...
mylabel.Text = "0"
bookingspanel.visible = false
nobookingspanel.visible = true

END IF


END SUB

</script>



<html>
<head>
<title>AgentShopper</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/todd.css" rel="stylesheet" type="text/css">



<!-- #include file="topsec.aspx" -->


<!--- START OF BOOKINGS PANEL--->
<form runat="server">


<asp:panel ID="bookingspanel" runat="server">
<asp:label ID ="mylabel" runat="server"/>

<asp:DataList id="dlBookings"
runat="server"
cellpadding="3"
cellspacing="3"
GridLines="Both"
borderstyle="solid"
backcolor="#FFFFFF"
width="790px"
headerstyle-font-name="Verdana"
headerstyle-font-size="11pt"
headerstyle-horizontalalign="left"
headerstyle-font-bold="false"
itemstyle-backcolor="#FFFFFF"
itemstyle-forecolor="#000000"
alternatingitemstyle-backcolor="#C6EFF7"
alternatingitemstyle-forecolor="#FFFFFF"
footerstyle-font-size="9pt"
footerstyle-font-italic="true">



<HeaderTemplate>
<table width="790" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td align="left" colspan="7" class="textbox"><%= Session("sesempFname") & "
" & Session("sesempLname")%>'s Draft Bookings - <asp:label runat="server"
ID="mylabel"></td> ********* MY LABEL's LOCATION IS WITHIN A DATALIST
</tr>
<tr height="15">
<td align="left" colspan="7"></td>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr valign="top">
<td align="left" class="textbox"><%#Container.DataItem("arn")%></td>
<td align="left" class="textbox"><%#Container.DataItem("status")%></td>
<td align="left" class="textbox"><%#Container.DataItem("bookingid")%></td>
<td align="left" class="textbox"><%#Container.DataItem("agencyid")%></td>
<td align="left" class="textbox"><%#Container.DataItem("clientid")%></td>
</tr>
</ItemTemplate>

<AlternatingItemTemplate>
<tr valign="top">
<td align="left" class="textbox"><%#Container.DataItem("arn")%></td>
<td align="left" class="textbox"><%#Container.DataItem("status")%></td>
<td align="left" class="textbox"><%#Container.DataItem("bookingid")%></td>
<td align="left" class="textbox"><%#Container.DataItem("agencyid")%></td>
<td align="left" class="textbox"><%#Container.DataItem("clientid")%></td>
</tr>
</AlternatingItemTemplate>

<FooterTemplate>
<tr height="15">
<td align="left" colspan="7"></td>
</tr>
<tr valign="top">
<td align="left" colspan="7" class="textbox">© Footer Info Here</td>
</tr>
</table>
</FooterTemplate>

</asp:DataList>





<!--- END OF BOOKINGS PANEL --->
</asp:panel>
 
C

Chris R. Timmons

Joe,

Remove this declaration from your code:

Dim mylabel as New Label

When the VB code and ASP.NET code are in the same file, .Net will
automatically create declarations for all of the web controls.


Hope this helps.

Chris.
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top