Sunday 15 August 2010

database - C# Reusing an Adapter to populate other controls -


I am using the following code to populate DataGridView (sqliteAdapter is obtained from DbDataAdapter):

  sqliteAdapter.SelectCommand.CommandText = SQLCommand; SqliteConn.Open (); (Using datatable dt = new datatile ()) {sqLiteAdapter.Fill (dt); DataGridRes.DataSource = DT; }  

The actual SQL command is:

  Select Email as NOTNULL, SEL, Regio, Distro, Groupo, MG, ID, Nom, Morada, E -mail evaluators  

Now, I want to use this datatale again to populate other controls in the form. I.e. 4 checked checkbox control I was hoping to avoid any other connection with DataData, as if to do something like "filtering" to the current datatelle (invalid code. Only the illustrative)

 < Select> Regiao separately from code> Datatyes Select specific distributes from the data selection  

The adapter and datatable properties and methods have been meaningless to me.

Controls can not be compelled for any archive, not just data-able.
So you can use LINQ, like:

  myControl.DataSource = Dt.AsEnumerable (). Select (DR = & gt; dr.Field & lt; string & gt; ("regio")). () (Toyare);  

No comments:

Post a Comment