C
codeWarrior
Hi
I'm having trouble accessing controls in an ASP code behind file. Here is an example
HTML
<asp:Table id="commentTable" runat="server" Visible="False"><asp:TableRow><asp:TableCell><asp:Repeater Runat="server" ID="comments" DataSource='<%#DisplayComments(DataBinder.Eval(Container.DataItem, "ID")) %>'><ItemTemplate><%# DataBinder.Eval(Container.DataItem, "CommentBody") %></ItemTemplate></asp:Repeater></asp:TableCell></asp:TableRow></asp:Table
C# code behin
protected System.Web.UI.WebControls.Table commentTable
private void Page_Load(object sender, System.EventArgs e
if (!IsPostBack
commentTable.Visible = false;
When the page loads for the first time, and enters the above condition, I always get this error
System.NullReferenceException: Object reference not set to an instance of an objec
However the commentTable is decalared at the top of the codeBehind, and maps to the HTML element with the same ID
If you've expierience a simialar problem, please relay your solutions. Thanks in advance.
I'm having trouble accessing controls in an ASP code behind file. Here is an example
HTML
<asp:Table id="commentTable" runat="server" Visible="False"><asp:TableRow><asp:TableCell><asp:Repeater Runat="server" ID="comments" DataSource='<%#DisplayComments(DataBinder.Eval(Container.DataItem, "ID")) %>'><ItemTemplate><%# DataBinder.Eval(Container.DataItem, "CommentBody") %></ItemTemplate></asp:Repeater></asp:TableCell></asp:TableRow></asp:Table
C# code behin
protected System.Web.UI.WebControls.Table commentTable
private void Page_Load(object sender, System.EventArgs e
if (!IsPostBack
commentTable.Visible = false;
When the page loads for the first time, and enters the above condition, I always get this error
System.NullReferenceException: Object reference not set to an instance of an objec
However the commentTable is decalared at the top of the codeBehind, and maps to the HTML element with the same ID
If you've expierience a simialar problem, please relay your solutions. Thanks in advance.