C1 Gridview Wijmo not looping foreach statement

Originally Posted 26 May 2014, 4:14 am EST

  • Originally Posted 26 May 2014, 4:14 am EST

    Not Looping


    this.C1Gridview.DataSource = dt;
    this.C1Gridview.DataBind();

    foreach (C1BoundField col in C1Gridview.Columns)
    {
    switch (col.HeaderText)
    {
    case "ID":
    col.HeaderText = "Sample";
    break;
    }
    }
  • Reply

    More specific code preview. Still need an Answer.


    DataTable dt = new DataTable();
    GetDataSet("SELECT * FROM MyTable").Tables[0];

    this.C1Gridview.DataSource = dt;
    this.C1Gridview.DataBind();

    foreach (C1BoundField col in C1Gridview.Columns)
    {
    switch (col.HeaderText)
    {
    case "ColumnName";
    col.HeaderText = "NewColumnName";
    break;
    }
    }


    It displays the DataSource in C1GridView, but it does not continue in foreach statement. Which means there is no data. Why?
  • Reply

    Hello,

    The ForEach loop does not run because the column collection is empty. By design, the Columns property only contains user-defined columns. In order to customize, you may use the RowDataBound/RowCreated events.

    Regards
  • Marked as Answer

    Reply

    @ashishjindal said:
    Hello,

    The ForEach loop does not run because the column collection is empty. By design, the Columns property only contains user-defined columns. In order to customize, you may use the RowDataBound/RowCreated events.

    Regards







    Thanks! now it works fine! :)

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels