in Education by
I recently began working on a project which has many gridviews on a single page. During creation of a new record, the user needs to be able to add/remove/edit these gridviews and then save to the database at the end. The problem with this obviously is that there is no datasource to bind the data too until after its written to the database. This data represents a 1..* relationship, which is why the gridview data cannot be written to the database until the parent record has been created first. The best way I have found so far to solve this is to use viewstate. This solution however does not seem ideal to me. I am also forced to manually create the gridview functionality with OnDeleting, OnUpdating, etc so that I can manage the binding of the viewstate with the gridview. Does anyone have any suggestions on a better way to manage this situation, it seems like it would be a common thing? UPDATE: Keep in mind this data needs to be around throughout postbacks. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Use a DataSet as an intermediate connection to your data source. Fill the DataSet with your data and then bind your GridView to the DataSet setting the GridView DataMember to the name of the table it is supposed to bind to. As the user updates tables it will add/modify records in the DataTables in the DataSet. When the user is done editing and clicks "Save" your code can then update the database from the datasets, either automatically using a DataAdapter, or manually looking at the RowState of the rows in the DataTables.

Related questions

0 votes
    I recently began working on a project which has many gridviews on a single page. During creation of a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    I recently began working on a project which has many gridviews on a single page. During creation of a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    I created a brand new Web Application, .NET Full Framework 4.7.2, added Application Insights Snapshot ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    When Forms Authentication is enabled, once the user provides a username and password it will be validated ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I have an ASP.NET MVC website. In my backend I have a table called People with the following ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    How can I mock the database calls to make my application logic been tested without database? JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    How can I mock the database calls to make my application logic been tested without database? JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    How can I mock the database calls to make my application logic been tested without database? JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    How can I mock the database calls to make my application logic been tested without database? JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I have already tried to make a login form and I also want to display the user login profile that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have already tried to make a login form and I also want to display the user login profile that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    So I am having trouble with setting the state for the date selected from this DatePicker change: change = ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    So I am having trouble with setting the state for the date selected from this DatePicker change: change = ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
0 votes
    I have an issue refrerencing an assembly in a view for MVC. This namespace is part of a dll I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
...