What are the options for displaying items in a list?

I’ve been trying to figure out how to create an interface that allows users to enter several rows of data and transfer these records to the SQL server database in just one shot. I could not get any better ideas, so I came up with this (see picture below). alt text

I assumed that the user enters values ​​in the text fields and clicks the add to list button. The values ​​are then filled in the list below with the heading "exhibit lists", and when the add exhibit button is pressed, all values ​​from the list field are transferred to the database.

Well, I’m wondering again whether it is possible to link these values ​​from text fields to a list box and whether it is possible to transfer them to the database.

If it were possible, I would be pleased to know how to do it, otherwise I would be glad if you would recommend me the best way to deal with the situation, otherwise I would have to solve the problem of data entry at that time.

I believe that this website has useful information that can help solve my problem, but I just can’t make the heads or tails of the article ... it looks like I'm almost there, and it disappears. Can everyone read and help me adapt it to my situation? The message below:

http://www.codeproject.com/KB/aspnet/ExtendedGridView.aspx

+4
source share
2 answers

Yes it is possible. I have done this twice before.

Check out the “Data Access Tutorials” at http://www.asp.net/web-forms/data for ideas.

Overview

  • For the user interface, you need a data entry form above the data grid.
  • For an internal server, you need a data adapter (or a table adapter) that downloads and saves data to the database in one operation.

You must use the DataSet and DataAdapter to update the database and manage the DataRow for input and DataTable for the list. Note: a list box is a data grid, repeater, or other control that accepts a DataTable as a DataSource .

  • DataAdapter populates a DataSet that contains a DataTable .

  • Input controls are bound to a DataRow created from a DataTable . When the user clicks the add-to-list button, you add a data row to the data table, and then create a new data row for the next item.

  • When the user clicks the add-exhibit button, simply use the DataAdapter to update the database. Any changed, deleted and added data is processed for you.

+1
source

Can you use a transaction to encapsulate all the sql queries you are trying to run so that you can then simply “commit” the transaction in the same database? Do you still have problems with this problem?

0
source

Source: https://habr.com/ru/post/1335428/


All Articles