CodeSmith Community
Your Code. Your Way. Faster!

Admin WebSite (Object reference null exception)

Latest post 05-12-2007 5:14 PM by matt@kiwilamb.com. 6 replies.
  • 05-10-2007 11:51 PM

    Admin WebSite (Object reference null exception)

    This one is easy to reproduce. Follow these steps to see the bug for yourself. Using netTiers2.0.1

    In the Admin Website that is generated....
    Click one of your tables in the left hand menu and the GridView will load.
    Now by default you see 10 records per page.
    Change the "Records Per Page:" to say 20
    Now we have 20 records on the page
    Selecting any record above the Record number 10 will cause the "Null Exception" in the method below on this piece of code "GridView1.SelectedDataKey.Values[0]);"

    protected void GridView_SelectedIndexChanged(object sender, EventArgs e)
    {
    string urlParams = string.Format("Pk={0}", GridView1.SelectedDataKey.Values[0]);
    Response.Redirect(
    "_whatever.aspx?" + urlParams, true);
    }

    If you select any record between 1-10 it is fine.... 
    Hope you can fix it.

    Thanks
    Matt

    • Post Points: 35
  • 05-11-2007 6:18 PM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 726
    • Points 16,880

    Re: Admin WebSite (Object reference null exception)

    Hmm ... i couldn't reproduce the issue ... Could you may be post the entire exception stack?

     

    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 35
  • 05-11-2007 6:45 PM In reply to

    Re: Admin WebSite (Object reference null exception)

     

     

    System.NullReferenceException was unhandled by user code
      Message="Object reference not set to an instance of an object."
      Source="App_Web_17wc5cfe"
      StackTrace:
           at _YBC_Shows.GridView_SelectedIndexChanged(Object sender, EventArgs e) in c:\Documents and Settings\MJLamb\My Documents\My Projects\yBC\yBC.WebSite\Admin\_YBC_Shows.aspx.cs:line 26
           at System.Web.UI.WebControls.GridView.OnSelectedIndexChanged(EventArgs e)
           at System.Web.UI.WebControls.GridView.HandleSelect(Int32 rowIndex)
           at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
           at System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    • Post Points: 5
  • 05-12-2007 12:17 AM In reply to

    Re: Admin WebSite (Object reference null exception)

    Also Mike there is something else here that does not function correctly with my implementation of NetTiers v2.0.1.

    When I do a sort on the grid on one of the columns; I then click the select link and get to the edit screen ok.

    However the record that is loaded for editing is not the one I click on in the grid. i.e. the PK's are getting mixed up during the sorting function.

    Hope you can solve that one also.

    Cheers

    Matt

    • Post Points: 35
  • 05-12-2007 3:00 PM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 726
    • Points 16,880

    Re: Admin WebSite (Object reference null exception)

    Matt,

    I haven't been able to replicate the problem ... the only issue i've come across is that if Typed DataSource's EnableCaching turned on, grid sorting stops working. Are you by any chance using any sort of caching?

     

    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 35
  • 05-12-2007 4:46 PM In reply to

    Re: Admin WebSite (Object reference null exception)

    Ok I'm just using the standard Admin website so if there is caching somewhere in the data layers then that would on turned on if it on by default.

    I have not implemented any caching myself. Just the code out of the box.

    Is there any default caching happening on the data layers that I could turn off.

    The only other thing I can think of at this stage is that I'm not using SQL SPROCS and are using the Parameteritised Queries that are the default.

     

    Cheers

    Matt

    • Post Points: 5
  • 05-12-2007 5:14 PM In reply to

    Re: Admin WebSite (Object reference null exception)

    Mike also have just implemented Stored Procedures into the database and turned on in web.config.

    The same Null issues is occuring.

    Cheers

    Matt

    • Post Points: 5
Page 1 of 1 (7 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems