Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
How to bind to DataTable.Column.Caption instead of DataTable.Column.ColumnName?
posted

DataTable dt = new DataTable();
dt.Columns.Add("col1").Caption = "column one";
dt.Columns.Add("col2").Caption = "column two";
dt.Columns.Add("col3").Caption = "column three";
dt.Rows.Add("val11", "val12", "val13");
dt.Rows.Add("val21", "val22", "val23");
DataView dv = new DataView(dt);
WebDataGrid1.DataSource = dv;
WebHierarchicalDataGrid1.DataSource = dv;

After performing this code you will see WebDataGrid with Captions from DataTable (dt)
And WebHierarchicalDataGrid will show ColumnNames (instead of Captions) from DataTable (dt)

Why and how to fix it?

Parents
No Data
Reply
  • 29417
    Verified Answer
    Offline posted

    Hello arseny ,

     

    Thank you for posting in our forum.

     

     WebHierarchicalDataGrid should not be bound  to a non-hierarchical data source like a data table. If you want to have a WebHierarchicalDataGrid with a single level of data you can bind it to a DataSet with just one  DataTable. For example:

    DataTable dt = new DataTable();

            dt.Columns.Add("col1").Caption = "column one";

            dt.Columns.Add("col2").Caption = "column two";

            dt.Columns.Add("col3").Caption = "column three";

            dt.Rows.Add("val11", "val12", "val13");

            dt.Rows.Add("val21", "val22", "val23");

            DataView dv = new DataView(dt);

            WebDataGrid1.DataSource = dv;

     

            DataSet set = new DataSet();

            set.Tables.Add(dt);

            WebHierarchicalDataGrid1.DataSource = set;

     

     

    You can see a list of the supported data sources for the WebHierarchicalDataGrid here: http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=WebHierarchicalDataGrid_Data_Binding.html

     

    Let me know if you have any questions.

     

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://ko.infragistics.com/support

     

Children
No Data