Select distinct values from a large DataTable column

Method 1: DataView view = new DataView(table); DataTable distinctValues = view.ToTable(true, “id”); Method 2: You will have to create a class matching your datatable column names and then you can use the following extension method to convert Datatable to List public static List<T> ToList<T>(this DataTable table) where T : new() { List<PropertyInfo> properties = typeof(T).GetProperties().ToList(); … Read more

DataTable internal index is corrupted

I just had the same issue while importing rows, as it seems, calling DataTable.BeginLoadData before the insert fixed it for me. Edit: As it turns out, this only fixed it on one side, now adding rows throws this exception. Edit2: Suspending binding as suggested by Robert Rossney fixed the adding problem for me, too. I … Read more

How to make datatable row or cell clickable?

To activate click on cell you must use a delegated event handler – this will work on any dataTable : $(‘.dataTable’).on(‘click’, ‘tbody td’, function() { //get textContent of the TD console.log(‘TD cell textContent : ‘, this.textContent) //get the value of the TD using the API console.log(‘value by API : ‘, table.cell({ row: this.parentNode.rowIndex, column : … Read more

How to compare 2 dataTables

public static bool AreTablesTheSame( DataTable tbl1, DataTable tbl2) { if (tbl1.Rows.Count != tbl2.Rows.Count || tbl1.Columns.Count != tbl2.Columns.Count) return false; for ( int i = 0; i < tbl1.Rows.Count; i++) { for ( int c = 0; c < tbl1.Columns.Count; c++) { if (!Equals(tbl1.Rows[i][c] ,tbl2.Rows[i][c])) return false; } } return true; }

How do you change the style of cell in a JQuery.DataTable?

Cool, I am happy to report that I was able to answer my own question! I just defined a CSS style (alignRight), and added the style to the column like so: <style media=”all” type=”text/css”> .alignRight { text-align: right; } </style> oTable = $(‘#example’).dataTable( { “aoColumns” : [ { sWidth: ‘40%’ }, { sWidth: ‘60%’, sClass: … Read more

how to add new rows into a datatable vb.net

Here is an example of adding a new row to a datatable that uses AutoIncrement on the first column: Define the table structure: Dim dt As New DataTable dt.Columns.Add(“ID”) dt.Columns.Add(“Name”) dt.Columns(0).AutoIncrement = True Add a New row: Dim R As DataRow = dt.NewRow R(“Name”) = txtName.Text dt.Rows.Add(R) DataGridView1.DataSource = dt

WPF DataGrid RowHeader databinding

I tried both answers, and neither worked for me. Essentially what I had to do was mix them together. This works for me: <DataGrid name=”ui_dataGrid> <DataGrid.RowHeaderTemplate> <DataTemplate> <TextBlock Text=”{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}, Path=Item.Header}”/> </DataTemplate> </DataGrid.RowHeaderTemplate> </DataGrid> The trick is to find the ancestor DataGridRow, then Bind the TextBlock.Text attribute to its Item’s property that … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)