custom data column headers, specific columns with web data grid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

After I made a nice application with WINFORM I tried to apply much of the same code, but there are lost of differences.

I load the grid colors, column width, column header from a xml data file.
But when I use datagrid.bind - it pulls in all the data to its own columns.
[ I want to apply the style and not show some columns ]

Ex:
gridTX.DataSource = ds.Tables[mappTableName];
this.AttachXMLdrivenStyle(gridTX,mappTableName);
gridTX.DataBind(); // my columns are not mapped over....but stand alone.
// best way to do this ??? there is no mapping name
// as in the winform....

private void AttachXMLdrivenStyle(System.Web.UI.WebControls.DataGrid gridTX,string mapTableName)
{ // read the definitions for the table styles...
gridTX.BackColor= this.getBackColor(mapTableName);
gridTX.AlternatingItemStyle.BackColor = this.getAlternatingBackColor(mapTableName);
int tabIndex = this.getStyleIndex(mapTableName);
int numCols= tabStyles.table[tabIndex].columns.GetLength(0);

for (int i =0;i< numCols;i++)
{ System.Web.UI.WebControls.DataGridColumn dgCol;
System.Web.UI.WebControls.BoundColumn bCol = new System.Web.UI.WebControls.BoundColumn();
dgCol=bCol;
dgCol.ItemStyle.Width=Convert.ToInt16(tabStyles.table[tabIndex].columns.width);
dgCol.HeaderText=tabStyles.table[tabIndex].columns.headertext;;
gridTX.Columns.Add(dgCol);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top