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.D ataItem("Number")) %>
</strong>
<br />
<%#displayLyrics(Container.DataItem("Text"))%>
<br />
</font></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</p>
<p>
</p>
</form>
</body>
//.................................................. ....
Thanks in advance,
George