CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Dec 2001
    Location
    UK
    Posts
    308

    DataList error - trying to amend the table infromation...

    I'm using 'User Controls' to define the 'Page header' for every webpages...
    In User Control - there is a DataList control to display the site-navigation-links (i.e. Home, About us, Contact us)...

    In 'ascx' page of the user control -
    <ItemTemplate> is used to define the links within the <asp:table> control... After DataBind() is done, i wanted to change the "Cssclass" value of "Table"...

    but i'm getting below error message, what wrong with code.. ??

    Basically, i'm trying to achieve making the 'tab like' structure and indicating 'Active' and 'Inactive' tabs

    (project is attached - "Fixtures.aspx" implements above logic )
    Thanks in adv.


    Code:
     Error message
    System.NullReferenceException: Object reference not set to an instance of an object

    Code:
    ascx code
    	<ItemTemplate>
    		<asp:Table ID=tHeader Runat=server>
    		      <asp:TableRow Runat=server ID=rHeader>
    			<asp:TableCell Runat=server ID=cHeader>
    					
    			<asp:HyperLink ID="lnkTabs" Runat="server" 
    				text='<%#DataBinder.Eval(Container.DataItem, "Name")%>'
    				NavigateUrl='<%#DataBinder.Eval(Container.DataItem, "Url")%>'>
    				</asp:HyperLink>
    			
    			</asp:TableCell>
    		     </asp:TableRow>
    		</asp:Table>	
    	</ItemTemplate>
    
     page behind code 
    	private void Page_Load(object sender, System.EventArgs e)
    	{
    		:
    		DataList1.DataBind();.....
    		:
    		TableCell tc = (TableCell )Page.FindControl("cHeader");
    		tc.CssClass = "InactiveTab";
    		:
    	}
    Attached Files Attached Files
    Venu Bharadwaj
    "Dream it. U can do it!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured