RE: DataGrid - how to configure columns in C# code?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Bond,
You can download some sample code which illustrates the same here
http://www.expertszone.com/samples/checkboxdatagrid.zip
Hope that helps ..
--
The best
srini
http://www.expertszone.com


"Dmitry Bond." wrote:

> 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.
>
>
>
.



Relevant Pages

  • Re: How to Programmatically create a DataGrid
    ... its the first block of sample code on the first page. ... > But I can't find about Programmatically create a DataGrid in that article! ... >>> How can I display the DataGrid after creating it? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Random Numbers
    ... provided me some sample code for the use of dictionaries. ... intTmp = arr ... ''' uncomment this for testing ... take the frequency of the 1000 numbers and display on the top 20 ...
    (microsoft.public.excel.programming)
  • DVB/ATSC Sample Code
    ... Does anyone have any suggestions for pointing me to some sample code ... I would like to be able to display a non digital channel (i.e. channel ... Multiple digital TV cards (MyHD PCI, ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Display multiple records on a single form
    ... I have an access/vba application I'm trying to extend. ... potentially have any number of records which I'd like to display on a ... this type of form and possibly some sample code (or a URL to some sample ... controls I'd need to use to facilitate this functionality, ...
    (microsoft.public.access.gettingstarted)
  • Re: Display multiple records on a single form
    ... I have an access/vba application I'm trying to extend. ... potentially have any number of records which I'd like to display on a ... this type of form and possibly some sample code (or a URL to some sample ... controls I'd need to use to facilitate this functionality, ...
    (microsoft.public.access.forms)