Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to populate values from datatable into datagridview when a datatable column is equal to something (button text for examle)

$
0
0

I want to bind my datagridview with my datatable where my "tableNumber" column in my datatable is eqaul to some number, but I olso want decide by self in which cell in datagridview a value from my datatable should go, because I have button cells in my datagridview I dont want to bind with the table. Can someone give a simple example? I will appreciate any help.

I have tried this query code but nothing shows up:

var dataRow = table2.AsEnumerable().Where(x => x.Field<int>("TableNumber") == Convert.ToInt16(btn.Text)).FirstOrDefault();
            dataGridView1.DataSource = dataRow; 


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>