D
Dmitry Bond.
Hello All.
Could you please help me with DataGrid?
The situation is the following:
I have a DataSet with some data to display in DataGrid.
In the configuration file I have a (comma-separated) list of columns of that
DataSet to display.
The first column in DataGrid should contains checkbox, rest of columns
should be configured at run-time.
How can I do this?
Just to give you an idea I provide a piece of code:
private void gridReports_DataBinding(object sender, System.EventArgs e)
{
this.reportsView = new
DataView(this.reportsTabs.Tables[this.selectedTableIndex]);
this.reportsView.Sort = "title";
gridReports.DataSource = this.reportsView;
// get list of columns to display
ArrayList colList =
(this.ReportsEngineObj.GetMetadataItem("ReportsListColumns") as ArrayList);
// if not available - init default
if (colList == null)
{
colList = new ArrayList();
colList.Add("title");
}
foreach (string colName in colList)
{
TemplateColumn gc = new TemplateColumn();
gc.HeaderText = "<b>" + colName + "</b>";
gc.ItemTemplate = ???!!! <<=== here I have problems! I just do not
know what should be here...
gridReports.Columns.Add(gc);
}
}
I browse MSDN but samples I found have predefined set of columns defined in
ASPX file.
But I need to configure columns in C# code...
How can I do this?
WBR, Dmitry.
Could you please help me with DataGrid?
The situation is the following:
I have a DataSet with some data to display in DataGrid.
In the configuration file I have a (comma-separated) list of columns of that
DataSet to display.
The first column in DataGrid should contains checkbox, rest of columns
should be configured at run-time.
How can I do this?
Just to give you an idea I provide a piece of code:
private void gridReports_DataBinding(object sender, System.EventArgs e)
{
this.reportsView = new
DataView(this.reportsTabs.Tables[this.selectedTableIndex]);
this.reportsView.Sort = "title";
gridReports.DataSource = this.reportsView;
// get list of columns to display
ArrayList colList =
(this.ReportsEngineObj.GetMetadataItem("ReportsListColumns") as ArrayList);
// if not available - init default
if (colList == null)
{
colList = new ArrayList();
colList.Add("title");
}
foreach (string colName in colList)
{
TemplateColumn gc = new TemplateColumn();
gc.HeaderText = "<b>" + colName + "</b>";
gc.ItemTemplate = ???!!! <<=== here I have problems! I just do not
know what should be here...
gridReports.Columns.Add(gc);
}
}
I browse MSDN but samples I found have predefined set of columns defined in
ASPX file.
But I need to configure columns in C# code...
How can I do this?
WBR, Dmitry.