locked
Errors using DetailsView RRS feed

  • Question

  • User-1235641944 posted

    So i have a page within my visual studio website called myprofile.aspx so that once the user can log into the website (which they can successfully do) they can then edit and change their details. I have put a DetailsView up and linked it to my database, when i view in browser it comes up blank. I was told from a friend that I have to put some coding behind the screen I tried but it came up with errors the following code i used is:

    protected void Page_Load(object sender, System.EventArgs e)
    {
    Session("UserName") = System.Web.HttpContext.Current.User.Identity.Name;
    }

    It says The name 'Session' does not exist in the current context... Any help please?

     

    Monday, July 15, 2013 8:06 PM

Answers

  • User-1716253493 posted

    Try this

    protected void Page_Load(object sender, System.EventArgs e)
    {
       Session["UserName"] = System.Web.HttpContext.Current.User.Identity.Name;
    }

    use [] instead ()

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 15, 2013 9:03 PM
  • User-1235641944 posted

    I managed to fix those new errors thanks anyway!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 17, 2013 8:57 AM

All replies

  • User-1716253493 posted

    Try this

    protected void Page_Load(object sender, System.EventArgs e)
    {
       Session["UserName"] = System.Web.HttpContext.Current.User.Identity.Name;
    }

    use [] instead ()

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 15, 2013 9:03 PM
  • User-1235641944 posted

    Cheers, that was such a minor mistake that works but now I have another problem when i edit the current details and click update it says the following error message :

    No value given for one or more required parameters.

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    [OleDbException (0x80040e10): No value given for one or more required parameters.]
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1084188
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
    System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
    System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
    System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +167
    System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +113
    System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +394
    System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +697
    System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +95
    System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation) +1105
    System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +444
    System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
    System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +112
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
    System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125
    System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169
    System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

    Any Help please? doing my head in all i need to do is update the fields im half way there

    Monday, July 15, 2013 9:56 PM
  • User-1716253493 posted

    When you getting error, will be better if you also show the related code.

    The error just tell you that you need to give value to the parameters, or you have give null value to the parameter

    Monday, July 15, 2013 10:19 PM
  • User-1235641944 posted

    I managed to fix those new errors thanks anyway!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 17, 2013 8:57 AM