vendredi 11 novembre 2016

Getting value from checkbox checked in datagridview c#

I have problem about getting the value from checkbox checked in datagridview. I want to get all the Id where the checkbox checked, but I only got the latest checked only. Here is my code:

string Id = "";

ds_utilityTableAdapters.tbl_membersTableAdapter tam = new ds_utilityTableAdapters.tbl_membersTableAdapter();

ds_utility.tbl_membersDataTable dtm = new ds_utility.tbl_membersDataTable();

foreach (DataGridViewRow row in dgv_members.Rows)

{

if (row.Cells[0].Value != null && (Boolean)row.Cells[0].Value == true)

{

Id= row.Cells[1].Value.ToString();

// using Id to display in crystal report viewer
// but only read the latest checkbox value

dtm = tam.GetDataBy_SearchId(Id);

}

}

How to write a query to get all the value?




Aucun commentaire:

Enregistrer un commentaire