This question is locked. New answers and comments are not allowed.
Hello,
I recently start using RadGridView for SL 4 development for POC project for sharepoint 2010. I have problem with dynamic data binding.
Here is what I am doing, I am using light weight data table from here and my grid is created based on users requirement (if user want 3 rows grid has 3 rows) . Now example project mentioned works fine but when I assign column name on the fly as per my code below binding fails. I saw the list getting assigned to radgridview as List<Dynamicclass>()
So, Does anyone know why data binding fails in RadGridView when column names generated on the fly.
Code:
I recently start using RadGridView for SL 4 development for POC project for sharepoint 2010. I have problem with dynamic data binding.
Here is what I am doing, I am using light weight data table from here and my grid is created based on users requirement (if user want 3 rows grid has 3 rows) . Now example project mentioned works fine but when I assign column name on the fly as per my code below binding fails. I saw the list getting assigned to radgridview as List<Dynamicclass>()
So, Does anyone know why data binding fails in RadGridView when column names generated on the fly.
Code:
public MainPage()
{
InitializeComponent();
Random rnd = new Random();
DataTable table = new DataTable();
for (int i = 0; i <= col; i++)
{
var coln = "- " + i.ToString();
table.Columns.Add(new DataColumn() { ColumnName = coln, DataType = typeof(string) });
}
for (var r = 0; r < row; r++)
{
DataRow row = new DataRow();
for (int c = 0; c <= col; c++)
{
var coln = "- " + c.ToString();
row[coln] = "Hello";
}
table.Rows.Add(row);
}
RadGridView1.ItemsSource = table.ToList();
}
}
please do get data.cs and dynamic.cs files from post mentioned above it has code for light weight data table.