Hello
Right now, I am having a problem trying to access an Image Button's
Imageurl property from CodeBehind. The Image Button is inside the header
template of a datagrid and I want to programmatically (C#) change the
ImageUrl property of the Image Button. I have the following in my aspx
file (This is for one of the columns in the data grid):
<asp:TemplateColumn headerstyle-horizontalalign="Center" >
<template name="HeaderTemplate">
<asp:ImageButton ID="SortBySongName" runat="server"
AlternateText="Sort By Track Name"
ImageAlign="Middle"
CommandArgument="SortBySongName"
OnClick="Sort_Click"/>
</template>
<template name="ItemTemplate" >
<b><%# DataBinder.Eval(Container.DataItem,"SongName","{0}") %></b>
</template>
</asp:TemplateColumn>
Then I have a declared Image button above the page_load in the codebehind
file as follows:
protected System.Web.UI.WebControls.ImageButton SortBySongName;
When I try to programmatically (in CodeBehind) assign a url string to the
Image buttons ImageUrl property like below:
SortBySongName.ImageUrl = "http://192.168.0.1/etrackSQL/Images/Track.jpg";
I get the famous "Attempted to dereference a null object reference."
Any ideas?
Thanks in Advance,
Russell Gordon