This is a migrated thread and some comments may be shown as answers.

RadGrid bug? First two columns missing.

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hart
Top achievements
Rank 1
Veteran
hart asked on 02 Dec 2009, 01:28 PM
When manually adding data to a grid, the first two columns go missing.
See attached Bitmap and code below.
I am simply adding data to a Grid through via a table.
DataTable dt = new DataTable();     
  for (int i = 0; i < 5; i++)     
   dt.Columns.Add(new DataColumn("Col: " + i.ToString(), typeof(string)));     
  for (int i = 0; i < 5; i++)     
  {     
   DataRow dr = dt.NewRow();     
   dt.Rows.Add(dr);     
  }     
  RadGrid1.DataSource = dt;     
  RadGrid1.Rebind();     
  for (int i = 0; i < 5; i++)     
   for (int j = 0; j < dt.Columns.Count; j++)     
    RadGrid1.Items[i].Cells[j].Text = j.ToString();    
 
I thought this was going to be simple, but has turned into something a little more challenging.
Any thoughts?
Thanks,
HH

1 Answer, 1 is accepted

Sort by
0
Roland
Top achievements
Rank 1
answered on 02 Dec 2009, 03:03 PM
Hello,

In your code, try filling the datarow first, then bind to the grid:
 for (int i = 0; i < 5; i++)      
  {      
   DataRow dr = dt.NewRow();    
   dr[0] = ....  // etc 
   dt.Rows.Add(dr);      
  }      

Tags
Grid
Asked by
hart
Top achievements
Rank 1
Veteran
Answers by
Roland
Top achievements
Rank 1
Share this question
or