S
S
sorra2020-05-19 16:31:35
C++ / C#
sorra, 2020-05-19 16:31:35

How to implement delete and lookup in WPF DataGrid table?

I am writing a client-server application. It is necessary to implement search and delete in the table. The data in the table is displayed through the list List.

Table output code in c#:
connection.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "select * From Students";
            cmd.Connection = connection;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(_dataTable);
          
            foreach (DataRow row in _dataTable.Rows)
            {
                StudentsList.Add(new StudentsClass
                {
                    NumberStudents = Convert.ToString(row["Number_Students"]),
                    FirstName = Convert.ToString(row["First_Name_Students"]),
                    LastName = Convert.ToString(row["Last_Name_Students"]),
                    MidName = Convert.ToString(row["Mid_Name_Students"]),
                    Address = Convert.ToString(row["Address_Students"]),
                    Course = Convert.ToString(row["Course_Students"]),
                    BirthDay = Convert.ToString(row["Birthday_Students"])
                });
            }
            DeportamentsGrid.ItemsSource = StudentsList;


This is how the table menu looks like:
5ec3df7dcfe7a724675514.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2020-05-19
@yarosroman

Use ObservableCollection. Delete data in the collection, it will notify the grid about the change in the collection. Well, search for cases not by grid, but by collection, will linq help you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question