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

access gridview data in a static class in silverlight project

3 Answers 36 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Syed Nadeem
Top achievements
Rank 1
Syed Nadeem asked on 09 Jun 2010, 11:26 AM
Hi,

How can I access a Silverlight GridView control in a static class that I am using as a helper class.  I do not want to pass it as a method parameter from the Main.xaml.cs page (since this method is an event handler, I want to keep with the same signature). 

I am unable to get the GridView's items using MyRadGridView.Items (Code below)

Thanks in advance for you help.

Cheers,
Nadeem.


public static  void Hello(object sender, EventArgs e) 
        { 
            //I wasnt to get something like this 
             
            try 
            { 
                        foreach (var dataItem in MyRadGridView.Items) 
                        { 
                            var firstRow = MyRadGridView.ItemContainerGenerator.ContainerFromItem(dataItem) as GridViewRow; 
                         
                            // some code 
                          } 
              } 
 


3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 09 Jun 2010, 11:51 AM
Hello Syed Nadeem,

You can pass the instance of RadGridView in the static constructor of your static  class and store it in a field for further reference - e.g. use it later in the event handler.

Best wishes,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Syed Nadeem
Top achievements
Rank 1
answered on 09 Jun 2010, 11:59 AM
Hi Pavel,

But the values in the GridView keep changing everysecond, say for example I have a dispatcher timer object showing a timer in the grid and I would need the current data in the GridView (dyanmic). 

So, I doubt if it would be right to go with the Static Constructor.

Correct me if I am wrong or alternatives are always appreciated.

Cheers,
Nadeem.
0
Pavel Pavlov
Telerik team
answered on 09 Jun 2010, 12:06 PM
Hello Syed Nadeem,

Having the refference to the  RadGridView  is enough. You can always check the RadGridView.Items property ( within your event handler) and I asure you it will contain the fresh data anytime the event handler is called.

Greetings,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Syed Nadeem
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Syed Nadeem
Top achievements
Rank 1
Share this question
or