Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ASP.NET content control problem in Master page architecture

ASP.NET content control problem in Master page architecture

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabasewpf
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Faisal Khatri
    wrote on last edited by
    #1

    Hi all I am using ASP.NET 3.0 and I have a list box in content page. I am using Master Page architecture. I am binding data from the database into the listbox. but it gives me error of "object reference not set to an instance of an object". This is what I am doing.. ((ListBox)(this.FindControl("ctl00_ContentPlaceHolder1_lMondayFD1"))).DataSource = ds.Tables[0].DefaultView; Please guys any one can help me

    P 1 Reply Last reply
    0
    • F Faisal Khatri

      Hi all I am using ASP.NET 3.0 and I have a list box in content page. I am using Master Page architecture. I am binding data from the database into the listbox. but it gives me error of "object reference not set to an instance of an object". This is what I am doing.. ((ListBox)(this.FindControl("ctl00_ContentPlaceHolder1_lMondayFD1"))).DataSource = ds.Tables[0].DefaultView; Please guys any one can help me

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      Are you able to find other controls at the same place ? OR can you try like below : Note: Be sure if your Listbox control defined in Content Place holder

      ContentPlaceHolder mpContentPlaceHolder;
      ListBox lb;
      mpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
      if(mpContentPlaceHolder != null)
      {
      lb=(ListBox ) mpContentPlaceHolder.FindControl("yourListboxid");
      if(lb!= null)
      {
      lb.DataSource = ds.Tables[0].DefaultView;
      }
      }

      OR In case List box placed on Master page then use try like this:

      ListBox lb = (ListBox ) Master.FindControl("yourListboxid");
      if(lb!= null)
      {
      lb.DataSource = ds.Tables[0].DefaultView;
      }

      Parwej Ahamad R & D with IIS 5.0/6.0

      modified on Friday, June 6, 2008 11:59 AM

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups