Cellvalue doesn't retain while editing for dynamically added columns

2 posts, 0 answers
  1. Sharada
    Sharada avatar
    43 posts
    Member since:
    Mar 2009

    Posted 22 Dec 2010 Link to this post


     I am using TreeListView. 
     I am adding columns dynamically at runtime

    GridViewDataColumn column;

    for (int icnt = 1; icnt < ts.Days; icnt++) 


    column = new GridViewDataColumn();
    column.UniqueName = "key" + icnt.ToString();
    column.IsReadOnly = false;


    I am populating the cell data in RadTreeListView1_RowLoaded event.

    var row = e.Row as TreeListViewRow;

    foreach (GridViewCell cell in row.Cells)


     if (cell.IsLoaded)

    DateTime dates;

    if (DateTime.TryParse(cell.Column.Header.ToString(), out dates))

     string filter = "dates = '#" + dates.ToShortDateString().ToString() + "#'";

     DataRow[] dr = lobjdt.Select(filter);

     if (dr != null && dr.Length > 0)


    cell.Content = dr[0]["hours"].ToString();





    But I am facing one more diffrent problem.
    I want to edit cells of cloumns which I have added dynamically.
    I am able to click and edit the data ... but data gets disappeares when user leave the cell and click somewhere else in the window.

    Editing is working correctly in static clumns.
    Am I missing anything while adding columns ?

  2. Maya
    Maya avatar
    4062 posts

    Posted 27 Dec 2010 Link to this post

    Hello Sharada,

    May you provide a bit more details about the data source of the RadTreeListView ? What is its type ? Furthermore, it is not recommended to work directly with the content of the visual elements as they get recycled on scrolling. It is better to bind the corresponding column to a property of your business object.
    However, in order to provide you with an appropriate for you case solution, I would need more information about your project. Any relevant information would be helpful.

    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
Back to Top