1
Answer

How to auto sort datagridview when the user enter a new data

elham deljooei

elham deljooei

11y
1.5k
1
I have a DataGridViewX1 when get its data from Datatable. Now i want to sort it when the clerk add data to sql, DataGridViewX1 automatically sort and show new row.
i tested this code but it isn't correct.
     
            //Fill datatable
            adp = new SqlDataAdapter("FillDataGridViewWithClerk", conn);

            adp.Fill(dtbl);
            grd.AutoGenerateColumns = false;
               
           DataView view = dtbl.DefaultView;

          view.Sort = "clrk_Name, clrk_Family asc";
          grd.DataSource = view;

Answers (1)