IMG null reference <grr/>

E

Eskimo

My web control has a repeater in it,
in the header it has an IMG with an ID
why do I get the following?

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:


Line 226:
Line 227: if (strSortDirection == "ASC")
Line 228: courseTitleimg.Src="../../images/arrow_up.gif";
Line 229: else
Line 230: courseTitleimg.Src="../../images/arrow_down.gif";


the control (ascx):
....
<asp:Repeater id="CoursesRepeater" runat="server">
<HeaderTemplate>
<table id="tblCourses" class="" cellspacing="4" cellpadding="4"
width="100%">
<tr style="background-color:#E0E0E0">
<td>
<asp:CheckBox ID="CheckAll" OnClick="javascript:
return select_deselectAll (this.checked, this.id);"
text="courseId" runat="server" /></td>
<td>
<asp:LinkButton ID="LinkButton1" Runat="server"
OnClick="SortCourseTitle">Courses</asp:LinkButton><IMG id="courseTitleimg"
src="../../images/arrow_up.gif" runat="server"/></td>
<td>
<asp:LinkButton ID="Linkbutton2" Runat="server"
OnClick="SortLiveDate">Live</asp:LinkButton><IMG id="liveDtimg"
src="../../images/arrow_up.gif" runat="server"/></td>
<td>
<asp:LinkButton ID="Linkbutton3" Runat="server"
OnClick="SortUpdateDate">Updated</asp:LinkButton><IMG id="updateDtimg"
src="../../images/arrow_up.gif" runat="server"/></td>
</tr>
</HeaderTemplate>
....

the control code behind (ascx.cs):

....

protected System.Web.UI.HtmlControls.HtmlImage courseTitleimg;
protected System.Web.UI.HtmlControls.HtmlImage liveDtimg;
protected System.Web.UI.HtmlControls.HtmlImage updateDtimg;

....
the code snippet in the error is trying to set the IMG src attribute to
nothing, or the arrow_up.gif or the arrow_down.gif.

any ideas or clues?
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top