Grid Control Help Required

Originally Posted 15 August 2013, 2:59 pm EST

  • Originally Posted 15 August 2013, 2:59 pm EST

    Please guide to any sample with following problems i am facing

    1) How to add columns and rows manually so that it can be used later on for populating data manually

    2) Need to load data from database with using data source (Unbound Data Loading From Database)
  • Reply

    Hi aisonesystems,

    I apologize for the delay.

    1) You can add columns manually to C1GridView using the following code :

    C1BoundField col1 = new C1BoundField() { HeaderText = "Column1" };
    C1BoundField col2 = new C1BoundField() { HeaderText = "Column2" };

    However, it is not possible to add rows manually. C1GridView has to be bound to a datasource and cannot be used in unbound mode.

    2) What you can do is, you can add empty rows to the datasource and bind it to C1GridView. Then you may populate data in C1GridView using the following code :

    DataSet ds = new DataSet();
    DataTable table = ds.Tables.Add();

    DataRow row;

    for (int i = 0; i < 5; i++)
    row = table.NewRow();
    table.Rows.Add(row);//i.ToString(),(100 - i).ToString().ToString());

    C1GridView1.DataSource = ds;

    for (int i = 0; i < table.Rows.Count; i++)
    C1GridView1.Rows[i].Cells[0].Text = i.ToString();
    C1GridView1.Rows[i].Cells[1].Text = (100 - i).ToString();

    Hope it helps

  • Reply

    ok i got it
    thanks for the help
Need extra support?

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

Learn More

Forum Channels