-
Databinding
I have a filled datatable and I'm trying to bind it to a ListView control, I'm currently using that following code:
Code:
listView1.DataBindings.Add(new Binding("text", myDataTable, "ItemName"));
it compiles but doesn't seem to work, I know that the datatable is full. what am I doing wrong?
-
DataSource? DataValue? DataMember? DataBind?
and I always use a dataset to contain my datatables. but I have only worked with ASP.Net Data so far.....
Code:
OleDbConnection oCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\temp\\iis_outside_empty\\db\\NWIND.MDB;Persist Security Info=False");
OleDbDataAdapter oAdapter01 = new OleDbDataAdapter("SELECT CategoryID, CategoryName FROM Categories ORDER BY CategoryName;", oCon);
OleDbDataAdapter oAdapter02 = new OleDbDataAdapter("SELECT SupplierID,CompanyName FROM Suppliers ORDER BY CompanyName;", oCon);
oAdapter01.Fill(oData,"Products");
oAdapter02.Fill(oData,"Suppliers");
rptProducts.DataSource = oData.Tables["Products"].DefaultView;
rptSuppliers.DataSource = oData.Tables["Suppliers"].DefaultView;
Page.DataBind();
that is for a data repeater but the concept is the same
-
what is oData
Code:
public DataSet oData = new DataSet();
-
-
listView only has a DataBindings member, there is no Datasource member like with most controls
-
ahh
I don't know I am looking at the listview in the object browser but I don't see any databinding ifo you may have to just read the data in to the ListViewItemCollection yourself.