J
John
Hello all,
I'm trying to display a dataset into a datagrid and format the datagrid
columns but I'm having a hard time with it. I've tried the MSDN examples but
they don't seem to work.
Basically, what I want to do is that, on a button click, the dataset fills
up dynamically, binds to the datagrid, and displays the data. This is my
code:
mySql = "select itemID, OrderDate " +
"from ClientTrans where " +
"clientID = " + txtClientID.Text;
DBConnection DBConn = new DBConnection("SQLServer", mySql);
DataSet DSMyTrans = DBConn.Connection();
//I use either one of the following two for the databinding
//DGOrders.DataSource = MyTransDS.Tables["MyTable"].DefaultView;
//DGOrders.SetDataBinding(DSMyTrans, "");
I only need some way to format the columns in the datagrid (column width,
headertext, etc...) and I've searched through MSDN but to no avail. I've
tried TableStyles:
DataGridTableStyle myTS = new DataGridTableStyle();
ts1.MappingName = "Clients";
DataGridBoolColumn myDataCol = new DataGridBoolColumn();
myDataCol.HeaderText = "From Date";
myDataCol.MappingName = "Current";
ts1.GridColumnStyles.Add(myDataCol);
DGOrders.TableStyles.Add(ts1);
but nothing happens.
Are there any links that show how to format datagrids (from the dataset
fill)?
John
I'm trying to display a dataset into a datagrid and format the datagrid
columns but I'm having a hard time with it. I've tried the MSDN examples but
they don't seem to work.
Basically, what I want to do is that, on a button click, the dataset fills
up dynamically, binds to the datagrid, and displays the data. This is my
code:
mySql = "select itemID, OrderDate " +
"from ClientTrans where " +
"clientID = " + txtClientID.Text;
DBConnection DBConn = new DBConnection("SQLServer", mySql);
DataSet DSMyTrans = DBConn.Connection();
//I use either one of the following two for the databinding
//DGOrders.DataSource = MyTransDS.Tables["MyTable"].DefaultView;
//DGOrders.SetDataBinding(DSMyTrans, "");
I only need some way to format the columns in the datagrid (column width,
headertext, etc...) and I've searched through MSDN but to no avail. I've
tried TableStyles:
DataGridTableStyle myTS = new DataGridTableStyle();
ts1.MappingName = "Clients";
DataGridBoolColumn myDataCol = new DataGridBoolColumn();
myDataCol.HeaderText = "From Date";
myDataCol.MappingName = "Current";
ts1.GridColumnStyles.Add(myDataCol);
DGOrders.TableStyles.Add(ts1);
but nothing happens.
Are there any links that show how to format datagrids (from the dataset
fill)?
John