0

I have the data below, and I used RowFilter to filter the ID, and only show rows that have ID = 111. However, I need to create a "Next" button to be able to go to the next unique ID which is 222. The IDs are not incremental.

Original Table: enter image description here

Any tips on how to approach this? I am running out of options

string[] columnnames = file.ReadLine().Split('|');
                DataTable dt = new DataTable();
                foreach (string c in columnnames)
                {
                    dt.Columns.Add(c);
                }
                string newline;
                while ((newline = file.ReadLine()) != null)
                {
                    DataRow dr = dt.NewRow();
                    string[] values = newline.Split('|');
                    for (int i = 0; i < values.Length; i++)
                    {
                        dr[i] = values[i];

                    }
                    dt.Rows.Add(dr);

                }
                DataView dv = new DataView(dt);
                dv.RowFilter = "ID = '111'";
                dataGridView1.DataSource = dv;  

I used dv.RowFilter = "ID = '111'"; however how can I make it dynamic so it can go to the next ID= 222?

Thanks

Yared
  • 2,206
  • 1
  • 21
  • 30
Jane Doe
  • 21
  • 6
  • While running a query for 111 stores next available id value in a hidden field or as a data attribute on a button. When a user clicks on next pass that id to SQL and fetch the value of it. – nikunjM Nov 13 '17 at 19:20
  • Build the DataTable Get the Distinct of ID column (https://stackoverflow.com/questions/1199176/how-to-select-distinct-rows-in-a-datatable-and-store-into-an-array) And then iterate through that on click of Next – Viju Nov 13 '17 at 20:09

0 Answers0