It's me again. :/ I'm trying to get the ClientID of an object on the ItemDataBound event to attach to another object. When I run the code, I get the System.NullReferenceException error: Object reference not set to an instance of the object.
.aspx code:
.aspx.cs code:
What am I doing wrong this time?
Thanks!
tigerjade
"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." -- Martin Golding
.aspx code:
Code:
<asp:TemplateColumn HeaderText="Return Date">
<ItemTemplate>
<asp:Label ID="dateLabel" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "detReturnDateTime", "{0:D}")%>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="updateDateText" Runat="server" Font-Size="8pt" Text='<%# DataBinder.Eval(Container.DataItem, "detReturnDateTime", "{0:D}")%>' ReadOnly="True"></asp:TextBox><asp:HyperLink id="lbtnCalendar" runat="server" ImageUrl="images/calendar.gif"></asp:HyperLink>
</EditItemTemplate>
</asp:TemplateColumn>
.aspx.cs code:
Code:
protected void UserDetailsDataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
TextBox udt = (TextBox)e.Item.FindControl("updateDateText");
HyperLink calHL = e.Item.FindControl("lbtnCalendar") as HyperLink;
calHL.NavigateUrl = "javascript:openWin('PopupCalendar.aspx?field=Form1" + udt.ClientID + "','newWin','width=250,height=290,toolbars=no,scrollbars=no,resizable=yes');";
}
}
What am I doing wrong this time?
Thanks!
tigerjade
"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." -- Martin Golding