.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Object reference not set to an instance of an object in Nested Repeater Control of CheckBox List con

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :ASP.Net
 
 if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem))
            {
                Repeater rptsub = (Repeater)item.FindControl("rptsub");
                CheckBoxList Chksub = (CheckBoxList)rptsub.FindControl("Chksub");
                Label lblsubroot = (Label)rptsub.FindControl("lblsubroot");
                DataRowView row = (DataRowView)e.Item.DataItem;
                RootId = Convert.ToInt32(row["IdApplication"].ToString());
                MetadataPermissions metadataPermissions = new MetadataPermissions(); ;
                DataSet rptRootValues = new DataSet();
                rptRootValues = metadataPermissions.GetrptSubMenus(RootId);
                DataRow[] drows = rptRootValues.Tables[0].Select("IdApplicationroot = " + row["IdApplication"].ToString());
                foreach (DataRow chkpermsns in drows)
               {
                   
                   ListItem li = new ListItem(chkpermsns["PermissionName"].ToString());
                   Chksub.Items.Add(li);
                    
               }


Designpage.aspx

<asp:Repeater ID="rptroot" runat="server" OnItemDataBound="rptroot_ItemDataBound">
                    <ItemTemplate>
                        <td>
      


View Complete Post


More Related Resource Links

object reference not set to instance of an object - list has returns in Controller but nothing in th

  

I started talking about this issue in an other thread i posted which was originally about another error, so i figure i may get more response posting it as a new thread.

i am trying to get some information from my remote sql server and return it to a list on a strongly-typed view. i have used a .edmx file to map the database rather than writing individual model classes because I have a pre-existing, multi-tabled database.

on the controller, i have created an entity variable this way

iliteratimvc.Models.iliteratiEntities ilitAuth = new iliteratimvc.Models.iliteratiEntities();

and the controller code for returning the view is:

public ActionResult RecentMSS()
        {
            var rmss = (from m in ilitAuth.Manuscripts select new { m.MsTitle, m.MsDescription });
            var rmssList = rmss.ToList();
            return View(rmssList);
        }

the view code is:

@model IEnumerable<iliteratimvc.Models.Manuscript>

<h2>Manuscripts</h2>

@foreach (var m in Model)
    {
    <li>@m.MsTitle, @m.MsDescription </li>
    }

However, this returns an "Object Reference not set to an instance of an Object" error. The error occurs on the "@foreach" code on the view. Acting on advice I got on the other thread (thanks for y

Cannot access Label inside Repeater - "Object reference not set..."

  

I have a button on a page with a Repeater and an ObjectDataSource. To give credit where credit is due, the Repeater's paging functionality is courtesy of ScottGu. (However, I'm using ASP.NET 4.0 and SQL Server 2008, as opposed to ASP.NET 2.0 and SQL Server 2005.)

Anyway, in the button's click event, I need to access the Text property of a Label that's inside the Repeater because it's used as an input parameter in a stored procedure. I'm getting a NullReferenceException when trying to access the Label's Text property. I have researched this error and have tried a few different solutions (involving FindControl and the Repeater's ItemDataBound event), but I haven't been able to get it to work. Any suggestions, in VB or C#, would be greatly appreciated. The code is below.

somepage.aspx

<asp:Repeater ID="rptText" runat="server" DataSourceID="tbsDataSource">
<HeaderTemplate>
<table width="100%" cellspacing="1">
</HeaderTemplate>
<ItemTemplate>
<%-- some rows removed for brevity --%>
<tr>
<td><asp:Label

VS2010 Silverlight 4 - Getting "Object reference not set to an instance of an object" when loading a

  
In Visual Studio 2010 I'm trying to use the Blacklight Controls (http://blacklight.codeplex.com/releases/view/37652) in my own project (and actually included the Blacklight.Controls project in my solution so that I could debug what was going on) and... after making all the XAML changes needed to incorporate the Blacklight navigation menu with my stuff in the innermost grid... everything compiled ok when doing a Build.  When I run it there's a reference to a resource dictionary in the XAML that fails with the object reference error above.  The XAML is as follows:       <UserControl.Resources>       <controls:ResourceDictionaryManager x:Key="ResourceDictionaryManager">       <controls:ResourceDictionaryManager.ResourceDictionaries>       <controls:ResourceDictionaryCollection>       <controls:ResourceDictionary Path="/Blacklight.Showcase;component/ResourceDictionaries/DavesGlossyControls.xaml">       <controls:ResourceDictionary.ResourceKeys>       <controls:ResourceKeyCollection>       <controls:ResourceKey ResourceName="GlossyBlackScrollViewer" />       </controls:ResourceKeyCollection>     &

reference not set to an instance of an object.

  
Hi friends,I got this error. This application for  delete  multiple record in gridview using Check Box.Please verify it. I tried before one application, that one finally worked,That application also error occurred, but after some time it execute(automatic I didnt do anything) correctly,Please tell me why this type of error occurred.  Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: Line 153: if (chkdelete != null) Line 154: { Line 155: chkall.Checked = array.Contains(grideviewsasmple.DataKeys[i].Value); Line 156: Line 157: if (!chkdelete.Checked) Source File: c:\Inetpub\wwwroot\AdditionUpdate\Default.aspx.cs    Line: 155

Object Reference not set to an instance of an object

  
Hi All,While using listview to upload images I get the error message. "Object Reference not set to an instance of an object".Gallery.aspx is suppose to call ManagePhotoAlbum.aspxError generatedLine 5: Protected Sub LinqDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles LinqDataSource1.Inserted Line 6: Dim myPhotoAlbum As PhotoAlbum = CType(e.Result, PhotoAlbum) Line 7: Response.Redirect(String.Format("ManagePhotoAlbum.aspx?PhotoAlbumId={0}", _ Line 8: myPhotoAlbum.Id.ToString())) Line 9: End SubCode Behind Gallery.aspx.vbPartial Class Photo_Gallery    Inherits System.Web.UI.Page    Protected Sub LinqDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles LinqDataSource1.Inserted        Dim myPhotoAlbum As PhotoAlbum = CType(e.Result, PhotoAlbum)        Response.Redirect(String.Format("ManagePhotoAlbum.aspx?PhotoAlbumId={0}", _            myPhotoAlbum.Id.ToString()))    End Sub    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load    End S

Object reference not set to an instance of an object.

  
This one has been killing me for 2 days now, and it should be so simple.I have a button on a page with an onClick that calls a web service.  I get the above error (on Line 938, Sys.WebForms.PageRequestManagerServerErrorException) as soon as the button is clicked.  The error seems to occur the second that the service is called - I have verified that every step of  the client-side code works and does not contain null values.  When remote debugging, the exception hits as soon as it jumps over to the web service's source code, an indication that the reference to the server itself is also valid.The code: (bad spelling and formatting not mine... I inherited this and have been cleaning it up as I go)'btnClick event - removed the log-writing lines for clarity's sake Private Sub btnSendCIS_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendCIS.Click Dim dt As DataTable Dim retr As String = "" dt = createOrderTable() Dim client As New ProdEndpoints.CISPRODUCTIONClient() retr = client.CompleteOrders(dt) client.Close() tmRecive.Interval = tickinterval getallrecive() End Sub 'createOrderTable - creates the dt that is sent to the service, also with log-writing lines removed. verified this is not returned Null as the log-writing includes pulling ou

Null Reference Exception was not handled by user Object Reference not set to instance of an object

  
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Security.Principal;using System.Data;using System.Data.SqlClient;using System.Windows;using System.Collections; public partial class Default2 : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {     }    private bool tableCopied = false;    private DataTable originalDataTable;     protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)    {         if (e.Row.RowType == DataControlRowType.DataRow)        {            //string sValue = e.Row.Cells[3].Text;             if (!tableCopied)            {                originalDataTable = ((System.Data.DataRowView)e.Row.DataItem).Row.Table.Copy();                ViewState["originalDataTable"] = originalDataTable;      &nbs

Object reference not set to an instance of an object.

  
can anybody help me with this error??the error occurs in the first line of the if statement...i really dont know how to fix this problem.. please help..Dim GW1 As new GridView            GW1 = CType(Me.LoginView1.FindControl("GridView1"), GridView)            If GW1.PageCount < 1 Then                lblFromDept.Visible = True                ddlFromDept.Visible = True                SelectedFromDept.Visible = False                btnOK.Visible = True            Else                lblFromDept.Visible = False                ddlFromDept.Visible = False                SelectedFromDept.Visible = False                btn

Object reference not set to an instance of an object.

  
When  can debugg the code it will give the error "Object reference not set to an instance of an object.". The code is--     using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using SMC.AlphaAccounting.EntryControls; using SMC.AlphaAccounting.PlugIns; using SMC.PlugInContracts; using SMC.BusinessObjects; using SMC.Utils; using SMC; using SMC.AlphaAccounting; using SMC.AlphaAccounting.DataEntry; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinMaskedEdit; using Infragistics.Win.UltraWinToolbars; namespace WindowsApplication3 {     public partial class FormCountry : SmcDataEntry     {         private boGlChart boLocalGlChart;         private boVendors boLocalVendors;         public FormCountry()         {             InitializeComponent();             this.ultraNumericUniqueID.KeyDown += new KeyEventHandler(ultraNumericUniqueID_KeyDown);             this.ultraNumericUniqueID.KeyPress &

Object reference not set to an instance of an object.

  
Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)         Dim CUW1 As New CreateUserWizard         CUW1 = CType(Me.LoginView1.FindControl("CreateUserWizard1"), CreateUserWizard)         Dim p As ProfileCommon = DirectCast(ProfileCommon.Create(CUW1.UserName, True), ProfileCommon)         p.SelectFromDept = DirectCast(CUW1.CreateUserStep.ContentTemplateContainer.FindControl("ddlSelectFromDept"), DropDownList).SelectedValue         p.Save()     End Subanybody can help me with this error?? that error occurs in the p.SelectFromDept line...Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)        Dim CUW1 As New CreateUserWizard        CUW1 = CType(Me.LoginView1.FindControl("CreateUserWizard1"), CreateUserWizard)        Dim p As ProfileCommon = DirectCast(ProfileCommon.Create(CUW1.UserName, True), ProfileCommon)        p.SelectFromDept = DirectCast(CUW1.CreateUserStep.ContentTemplateContainer.FindControl("ddlSelectFromDept"), DropDownList).SelectedValue        p.Save()    End S

"Object reference not set to an instance of an object."

  
Working in Visual Web Developer 2008 Express Edition, attempting to configure data source (SqlDataSource),  able to include server name: (local)\sqlexpress and the "Test Connection" is successful.  However, when I try to make a new database (or load one of the samples), I keep getting an alert: "Object reference not set to an instance of an object."  I've posted in this forum under "Data Access: Sql Server, Sql Server Express..." with a response to remove and then reinstall VWD and SQL Express.  Thus, I've removed and reinstalled Sql Server 2008.  I tried to remove then reinstall VWD 2008 Express with "Windows Install Clean Up" and "Add / Remove Programs", but in Add/ Remove Programs, it just tried to reinstall without removing then stopped halfway and prompted me to insert a disc (which I don't have since it was an online download).  Not sure what is going on behind the scenes.  Don't know what the problem is as this was never an issue in VWD 2005 Express Edition. Does the problem involve Visual Web Developer 2008 Express Edition or SQL Server 2008?  Any suggestions on removing and then reinstalling VWD 2008 Express?  I feel like I'm missing something simple but after 3 days I'm getting nowhere... As always, help is much appreciated and tha

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

  
        BVWS.Vardering oWS = new BVWS.Vardering();        BVWS.strucBPVardering oSvar1 = new BVWS.strucBPVardering();        BVWS.StrucPaket oPaket = new BVWS.StrucPaket();                 if (Page.IsPostBack)        {             oSvar1 = oWS.BpVardering("", "", regnummer.Text, "2000", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", DropDownList1.SelectedValue);      tdCHK1.Visible = false;                  try            {                if (oSvar1.rubst01.Length > 0)                {                   

Object reference not set to an instance of an object.

  
When  can debugg the code it will give the error "Object reference not set to an instance of an object.". The code is--     using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using SMC.AlphaAccounting.EntryControls; using SMC.AlphaAccounting.PlugIns; using SMC.PlugInContracts; using SMC.BusinessObjects; using SMC.Utils; using SMC; using SMC.AlphaAccounting; using SMC.AlphaAccounting.DataEntry; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinMaskedEdit; using Infragistics.Win.UltraWinToolbars; namespace WindowsApplication3 {     public partial class FormCountry : SmcDataEntry     {         private boGlChart boLocalGlChart;         private boVendors boLocalVendors;         public FormCountry()         {             InitializeComponent();             this.ultraNumericUniqueID.KeyDown += new KeyEventHandler(ultraNumericUniqueID_KeyDown);             this.ultraNumericUniqueID.KeyPress &

Object reference not set to an instance of an object error.

  
i've installed the VSeWSS.msi on VS 2005, i'm using SPS 2007, i'm developing on my workstation in C#, i've added the Mircosoft.Sharepointserver dll reference to my project but i still can't deploy a very basic webpart. i get the "Object reference not set to an instance of an object" error but there's no reference to a line, column, project or anyhting. very frustrating. any suggestions/links whould be appreciated.

Login error - Object reference not set to an instance of an object.

  
Hi all,I've set up the login section as a user control. WheneverI log in I get a "Object reference not set to an instance of an object", with the code stopping on this line: if (Membership.ValidateUser(txtUserName.Text,txtPassword.Text))Can anyone tell me how to fix this please?protected void LoginButton_Click(object sender, EventArgs e) { TextBox txtUserName = loggedin.FindControl("UserName") as TextBox; TextBox txtPassword = loggedin.FindControl("Password") as TextBox; CheckBox ckbRememberMe = loggedin.FindControl("RememberMe") as CheckBox; if (Membership.ValidateUser(txtUserName.Text,txtPassword.Text)) { FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, ckbRememberMe.Checked); } else { // Msg.Text = "Login failed. Please check your user name and password and try again."; } } <asp:LoginView ID="loggedin" runat="server"> <AnonymousTemplate> <asp:Login ID="Login1" runat="server"> <LayoutTemplate> <table id="mainbox" width="400"> <tr> <td width="150" class="label">

Strange Repeater Error, Object reference not set, Label not visible etc etc..

  
Hi Everyone,This is very strange and as of yet I cant seem to get round it, although it is a somewhat easy error to identify it is however becoming very annoying as everything I try doesn't seem to work...The repeater displays results for upcoming subscribers birthdays and after their day and month ("dd/mm/") I have a label to display the current year. This causes the old error of: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:  Line 55: Label lblYear = e.Item.FindControl("lblYear") as Label;Line 56: Line 57: lblYear.Text = DateTime.Now.Year.ToString();Line 58: }Line 59: As you can see the object is set correctly - The ASPX is below, for saving time on reading etc I've posted the repeater script only and not the whole page, although I can do if needs be.I've tried a number of things with subtle differences but to no avail: with Literal, same error - Tried inserting the year directly via <%#((system.datetime).now.year.tostring())%> or something to that effect, this also doesnt

Error while export to pdf-Object reference not set to an instance of an object

  
Hello, I am getting error while rendering the report to pdf in SSRS 2008. This is happening randomly and sometimes I get this error. I have SQL Server 2008 SP1 installed in my system . I installed the cumulative update 1 for SP1 also but no luck. Every time when export to pdf fails, SSRS is creating the dump file in the logs. I have captured the log of this specific error. Please let me know if you have any idea about this.   reportrendering!ReportServer_0-297!1ec4!03/30/2010-10:32:57:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.UnhandledReportRenderingException: An error occurred during rendering of the report., ; Info: Microsoft.ReportingServices.ReportProcessing.UnhandledReportRenderingException: An error occurred during rendering of the report. ---> Microsoft.ReportingServices.OnDemandReportRendering.ReportRenderingException: An error occurred during rendering of the report. ---> System.NullReferenceException: Object reference not set to an instance of an object.   at Microsoft.ReportingServices.Rendering.HPBProcessing.Paragraph.get_SpaceBefore()   at Microsoft.ReportingServices.Rendering.RichText.LineBreaker.FlowParagraph(Paragraph paragraph, Directions direction, IntPtr hdc, Single dpiX, FontCache fontCache, FlowContext flowContext, Boolean keepLines, SizeF flowContextSize, Int32& contentOffset)   at Mi
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend