Home > Net >  C # how to obtain a datagridview column data
C # how to obtain a datagridview column data

Time:09-22

Such as ID student ID column because they cannot afford to repeat so you need to verify with the ID column data duplication

CodePudding user response:

The DataTable dt=datagridview1. The DataSource as DataTable
List Id=dt. AsEnumerable (). The Select (o=& gt; O.F ield (" ID ")). ToList ();

CodePudding user response:

If you will be inside the DataTable comparison or in SQL is actually there is no problem, you can put the database source into a DataTable his judgment
Write as DataTable support available inside the select query, so don't want to cycle can also write a query

CodePudding user response:

In the id column in the database is set to the primary key,
Without judgment, directly inserted into, plus the try catch, if repeated will enter the catch
  •  Tags:  
  • C#
  • Related