Header questions

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Gmansky (gmansky_at_starmd.net)
Date: 08/19/04


Date: Thu, 19 Aug 2004 06:52:00 -0700

Hi,

I have a page where I want to place the title of the song on the header. I
am getting an error:

System.NullReferenceException: Object variable or With block variable not
set.

I have the usual query and repeater on my page_load. What is the proper way
of placing the data field ('Title') on the <header Template>?

I placed the codes here for reference.

//......................................................
Sub Page_Load
  SongID = Request.QueryString("SongID")
  If SongID <> "" Then
     If Not Page.IsPostBack Then
       DBConnection = New OleDbConnection( _
         "Provider=Microsoft.Jet.OLEDB.4.0;" & _
         "Data Source=c:\Songs.mdb")
       DBConnection.Open()
     End If
     SQLString = "SELECT Title, Type, Number, Text FROM Lyrics
                 INNER JOIN Songs ON Lyrics.Record = Songs.Record
                 WHERE Songs.Record=" & SongID & " order by type, number "
     DBCommand = New OleDbCommand(SQLString, DBConnection)
     DBReader = DBCommand.ExecuteReader()
     SongRepeater.DataSource = DBReader
     SongRepeater.DataBind()
     DBReader.Close()
     DBConnection.Close()
  End If
End Sub

Function displayTitle(zTitle)
   Console.Write(zTitle)
End Function

//................................
<body style="FONT-FAMILY: arial">
    <h2>Song List
    </h2>
    <% Response.Write(DateTime.Now.ToString()) %>
    <hr size="1" />
    <form runat="server">
        <p>
            <asp:Repeater id="SongRepeater" runat="server">
                <HeaderTemplate>
                    <table border="0" cellpadding="3"
style="border-collapse: collapse" width="400">
                        <tr style="background-color:#F0F0F0">
                            <th width="400">
                                <font face="Arial" size="2">

<%#displayLyrics(Container.DataItem("Title"))%> </font>
                            </th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <font face="Arial" size="2"><strong> <%#
displayType(Container.DataItem("Type"),Container.DataItem("Number")) %>
                              </strong>
                            <br />
                            <%#displayLyrics(Container.DataItem("Text"))%>
                            <br />
                            </font></td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </p>
        <p>
        </p>
    </form>
</body>

//......................................................
Thanks in advance,
George



Relevant Pages

  • Re: Help, need to speed up this macro
    ... to do it once per worksheet, but it should speed things up significantly. ... Private Sub Workbook_BeforePrint ... > the header and footer on all worksheets with in the workbook. ... > For Each wkSht In ThisWorkbook.Worksheets ...
    (microsoft.public.excel.misc)
  • RE: Analyze with Excel
    ... Sub Build_XL_Report ... Const conLightGray As Long = 12632256 ... Dim varGetFileName As Variant 'File Name with Full Path ... 'Set Up Recordset for ITM Header data ...
    (microsoft.public.access.reports)
  • Re: Catching the New Page event in VBA
    ... Thanks for your reply, Doug. ... When, or if, the user starts a new page the different header will be used ... The reference number and the subject of the ... Private Sub wdApp_WindowSelectionChange ...
    (microsoft.public.word.vba.general)
  • Re: Making sections with their own header and footer
    ... Sub NewTestDocument() ... Dim Section As Long ... "There should be no header on this page, but the footer should be there!" ...
    (microsoft.public.word.vba.general)
  • Re: Control to use for sorting by column in continuous form
    ... I put the sub into a vba module and then call it from the click event of the label. ... Dim strUP As String ... Sort Fields, Sort records, sort columns ... I want to allow the user to click on the header and get some sort of indication of how the form is sorted. ...
    (microsoft.public.access.modulesdaovba)