panel problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chris

    panel problem

    Hi there,

    I have following code which receives Panel names from the database. It tells
    me Object reference not set to an instance of an object. Why is that? Thanks
    a lot for your help....
    Chris

    while (or.Read())

    {

    Panel pnl = new Panel();

    pnl = (Panel)FindCont rol(or.GetStrin g(0));

    pnl.Visible = false;

    }

  • Dmytro Lapshyn [MVP]

    #2
    Re: panel problem

    Hi,

    The most suspicious place seems to be this line:

    pnl = (Panel)FindCont rol(or.GetStrin g(0));

    If FindControl returns null, you'll get the NullReferenceEx ception.

    P.S. This line:

    Panel pnl = new Panel();

    seems to be unnecessary at all.

    --
    Sincerely,
    Dmytro Lapshyn [Visual Developer - Visual C# MVP]


    "chris" <chris@discussi ons.microsoft.c om> wrote in message
    news:68F4D854-10E1-4389-9986-F45DEED442C6@mi crosoft.com...[color=blue]
    > Hi there,
    >
    > I have following code which receives Panel names from the database. It
    > tells
    > me Object reference not set to an instance of an object. Why is that?
    > Thanks
    > a lot for your help....
    > Chris
    >
    > while (or.Read())
    >
    > {
    >
    > Panel pnl = new Panel();
    >
    > pnl = (Panel)FindCont rol(or.GetStrin g(0));
    >
    > pnl.Visible = false;
    >
    > }
    >[/color]

    Comment

    Working...