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?
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.
Member
17 Points
90 Posts
Change FK id via custom gridview page vs dropdown list
Sep 26, 2012 04:29 PM|jjfrick|LINK
Hello,
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?
Thanks,
Jeff
All-Star
94130 Points
18109 Posts
Re: Change FK id via custom gridview page vs dropdown list
Sep 27, 2012 10:02 PM|Decker Dong - MSFT|LINK
Hi,
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.