Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Panel with in Listview gives me an error(Object reference not set to an instance of an object.)


Panel with in Listview gives me an error(Object reference not set to an instance of an object.)

Reply
  #1 (permalink)  
Old 06-24-10, 01:52 PM
fzshah76 fzshah76 is offline
New Member
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rolleyes Panel with in Listview gives me an error(Object reference not set to an instance of an object.)

I have a panel in Itewmtemplate of list view it's only supposed to show when user is logged in, by default the visibility = false. Help is appreciated.

here is my c# code:

Code:
Panel pnlOptions = (Panel)ListView1.FindControl("pnlOptions");
    pnlOptions.Visible = true;
Aspx Code:

Code:
<asp:Panel ID="pnlOptions" runat="server" Visible="false">
    <ul>
        <ul>
        <li style="float: left">Option 1:</li>
        <li style="float: left">dropdown here</li>
        </ul>
    <li style="float: left">Option 1:</li>
    <li style="float: left">dropdwon here</li>
    </ul>

    </asp:Panel>
Reply With Quote
  #2 (permalink)  
Old 06-24-10, 02:20 PM
fzshah76 fzshah76 is offline
New Member
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
My problem was I was trying to acces it wrongly through a function I created when I was supposed to use the Item_Created Event here is the final working code:

Code:
protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e)
{
Control control = e.Item.FindControl("pnlOptions");
Panel pnlOptions = control as Panel;
pnlOptions.Visible = true;
}

Last edited by digioz; 06-25-10 at 08:22 AM. Reason: Code Tags
Reply With Quote
Reply

Bookmarks

Tags
asp.net, c sharp


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Object reference not set to an instance of an object. m.timoney Windows .NET Programming 6 04-20-09 03:06 AM
reference not set to an instance of an object. Please help! DonLindon ASP.NET 10 12-26-07 12:37 PM
Object reference not set to an instance of an object. Cabal Windows .NET Programming 2 02-15-07 05:40 AM
ASP upload prob minority ASP 1 06-27-05 08:35 AM
Error in OleDBConnection : Object reference not set to an instance of an object pvsunil Windows .NET Programming 1 04-22-05 01:45 PM


All times are GMT -5. The time now is 02:42 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.