Hi there,
this code works fine, but it shows me "System.Data.Row.View" instead of those real Content.
But, I gave that View a DataTable like that, then I got the real content:
I dont see any diffrent between a datable like this or a datatable wich will fill with an SQLAdapter?
XAML Code
Code-Behind
this code works fine, but it shows me "System.Data.Row.View" instead of those real Content.
But, I gave that View a DataTable like that, then I got the real content:
I dont see any diffrent between a datable like this or a datatable wich will fill with an SQLAdapter?
Code:
public DataTable myDataTable { get; set; }
myDataTable = new DataTable();
myDataTable.Columns.Add("Start");
myDataTable.Columns.Add("End");
DataRow dr = myDataTable.NewRow();
dr[0] = "Jo";
dr[1] = "Doug";
myDataTable.Rows.Add(dr);
DataRow dr1 = myDataTable.NewRow();
dr1[0] = "Jam";
dr1[1] = "Pearl";
myDataTable.Rows.Add(dr1);
Code:
<Window x:Class="Wpf_Binding_Listview.MainWindow"
xmlns="...schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="...schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Wpf_Binding_Listview"
Height="400" Width="500" Title="Binding Listview">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="138*" />
<ColumnDefinition Width="209*" />
<ColumnDefinition Width="156*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="76*" />
<RowDefinition Height="235*" />
</Grid.RowDefinitions>
<ListView Name="LvView1" Grid.Column="1" Grid.Row="1"/>
</Grid>
</Window>
Code:
public class Viewing
{
public BindingListCollectionView myView { get; set; }
public Viewing()
{
SqlConnection con = new SqlConnection();
SqlCommand myCmd = new SqlCommand();
DataSet ds = new DataSet();
con.ConnectionString = "Data Source=(local);" +
"Initial Catalog=Northwind;" +
"Integrated Security=sspi";
con.Open();
myCmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter();
myCmd.CommandText = "SELECT * FROM Shippers";
da.SelectCommand = myCmd;
da.Fill(ds, "tblShippers");
DataTable dt;
dt = ds.Tables["tblShippers"];
myView = new BindingListCollectionView(new DataView(dt) { RowFilter = "CompanyName like 'S%'" });
}