I am trying bind data from database into rich textbox here is my code:
DataTable NameTable = new DataTable("NameTable");
NameTable.Columns.Add("PropertyNo");
NameTable.Columns.Add("PropertyName");
DataSet NameSet = new DataSet();
NameSet.Tables.Add(NameTable);
selectQry = new SqlCommand("SELECT PropertyNo, PropertyName FROM Property", conn);
SqlDataAdapter DataAdpt = new SqlDataAdapter(selectQry);
DataAdpt.Fill(NameSet, "NameTable");
Binding NameBinding = new Binding("Text", NameSet, "NameTable.PropertyName");
NameRtb.DataBindings.Add(NameBinding);
I am getting only last value. Can anyone help me out.
Thanks.
I dont think this is possible, I personally like to bind Data Tables to DatagridView’s.
All you need to do is :-
Use a Binding Source, set its DataSource as the DataTable. You then set the Datasource fro the Datagridview as the Binding Source.
e.g below :-
//the DataGridView
DataGridView dgView = new DataGridView();
//BindingSource to sync DataTable and DataGridView
BindingSource bSource = new BindingSource();
//set the BindingSource DataSource
bSource.DataSource = dTable;
//set the DataGridView DataSource
dgView.DataSource = bSource;