Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have create a dynamic RadGridView and I load the data in the itemsource and add the RadGridView to a stackpanel.
I can see the data and sort it on the grid.
But when i use
foreach (GridViewColumn column in Firstcontrol.RadGridView1.Columns)

I only get the column name and not the data below the column.

Am I missing a binding somewhere?
This is the code where I create the collection and send it to itemsource.

int xxx = 0;
for (int j = 0; j < Rownum; j++) // Load Rows
{
var row = new ObservableCollection<dynamic>();
for (int ii = 0; ii < Colnum; ii++)
{
row.Add(statisticViewModelObect.StatisticCollection[TbCount].Rows.ElementAt(j).GetValue(xxx));
xxx++;
}
statisticCollection.Add(row);
xxx = 0;
}
Firstcontrol.RadGridView1.ItemsSource = statisticCollection;

StackPanel1.Children.Add(Firstcontrol);

//Rigth here is where I try to read the data that has been created on the grid.

foreach (GridViewColumn column in Firstcontrol.RadGridView1.Columns)


This is my xaml.--------------------------

<telerik:radgridview x:name="RadGridView1" horizontalalignment="Stretch" xmlns:x="#unknown" xmlns:telerik="#unknown">
ItemsSource="{Binding statisticCollection ,Mode=TwoWay}"
AutoGenerateColumns="False" ShowGroupPanel="False" Height="250"
VerticalAlignment="Top" IsReadOnly="True" CanUserSortColumns ="true" >
Posted

1 solution

have you check the documentation?
http://www.telerik.com/help/winforms/gridview-rows-iterating-rows.html[^]
there are lot of samples you can refer. for example
C#
string searchedStr = "Picture 2";
for (int r = 0; r < radGridView1.RowCount; r++)
{
    if (radGridView1.Rows[r].Cells["Picture Name"].Value.ToString().ToUpper().Equals(searchedStr.ToUpper()))
    {
        MessageBox.Show("Found a match");
        //do something 
    }
}
 
Share this answer
 
Comments
pierrewhy 13-Jun-14 11:20am    
Somehow I dont even have access to rowcount ro rows from my radgridview.
Or even GridViewDecimalColumn, I have to create a class to use it.
What references am I missing?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900