Change FK id via custom gridview page vs dropdown list RRS feed

  • Question

  • User1696625220 posted


    For simplicity, lets say I have a custom details page (SalesPerson) that contains a SaleCarID FK. I want to display more information than a dropdownlist can display such as Make, Model, Year,etc so I have a link that goes to gridview custom page. When the user selects a row from the gridview I want to replace the SaleCarID in the previous page formview with the new one selected from the gridview. What would be the best way to go about this?


    Wednesday, September 26, 2012 4:29 PM


  • User3866881 posted


    Your Logic is:

    1)Choose SaleId (suspected as a primary key) from dropdownlist , besides it shows the only one record bound to the FormView, please also save the primary key into Session.

    2) Then when goes to the GridView and when click a button, please in advance to handle the button's click event and fetch the GridView's ((sender) as Button).NamingContainer as GridViewRow).Cell[0-based index] to find out the a new foreign key, and then us SqlCommand to replace the old one with the new one by using where statement followed by the original primary key from Session.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 27, 2012 10:02 PM