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

Referencing Dynamically Created GridView

5 Answers 46 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eduardo Lorenzo
Top achievements
Rank 1
Eduardo Lorenzo asked on 22 Apr 2010, 06:04 AM
Hi guys,

Am in a bit of  rut here :)

I create a gridview through server-side C#, then bind it to data from a SL Enabled WCF WebServie (List<customers), add it to a stackpanel, add the stackpanel to the page and so on.

I have also attached a double click handler to the grid and I now do the edit in a modal window.

Next thing to do of course is to reflect the change in the data on the grid when the modal window is closed. Here lies my problem, how do I rebind to that grid if I can't reference it since it was created runtime?

For those who understand better with code, here are some snippets:
1. Create the grid
  newGrid = new RadGridView();
                    newGrid.Width = 800;
                    newGrid.Height = 400;
2. Bind it with wcfWebService
 void ws_CustomerListCompleted(object sender, CustomerListCompletedEventArgs e)
        {
            newGrid.ItemsSource = e.Result.ToList();
        }
3. Create the modal
modalPopup myModal = new modalPopup(cc); <-- cc is a customer object based on which row was doubleclicked
4. Modal pops up, populates the textboxes, then saves the record

What I would happen is, when the modal closes, the grid is rebound.

Thanks in advancE!



5 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 22 Apr 2010, 11:33 AM
Hi Eduardo Lorenzo,

Grid will be able to automatically update the its displayed values if the object that it is bound to implement INotifyPropertyChanged. Could you please check if the data objects implement INotifyPropertyChanged? Usually Visual Studio automatically generates classes which implement this interface.


Greetings,
Milan
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
Eduardo Lorenzo
Top achievements
Rank 1
answered on 23 Apr 2010, 01:46 AM
Hi Milan,

Am sure it does not implement it. Will apply now and get back as soon as I break it again. :)

Thanks in advance!

Edu
0
Eduardo Lorenzo
Top achievements
Rank 1
answered on 23 Apr 2010, 02:23 AM
Hi Milan,

I did an implementation on the object but it did not update. did I miss anything?
Here is part of the object

 public class Customer : INotifyPropertyChanged
    {
        
        public event PropertyChangedEventHandler PropertyChanged;
        private string accountNum;
     
        public string AccountNumber
        {
            get { return accountNum; }
            set
            {
                accountNum = value;
                  OnPropertyChanged("AccountNumber");
            }
        }

      
        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }
    }

Do I have to do any changes with the WCFWebservice also?
0
Milan
Telerik team
answered on 28 Apr 2010, 08:27 AM
Hi Eduardo Lorenzo,

Will it be convenient for you to send us the application? It will really help us to pinpoint the exact problem. 


Regards,
Milan
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
Eduardo Lorenzo
Top achievements
Rank 1
answered on 29 Apr 2010, 02:51 AM
Hi there,

Am currently remodeling to implement LinQ to SQL DBML as I know it implements the propertychanged handler.
Will update if it does not work.

Thanks in advance!

Edu
Tags
GridView
Asked by
Eduardo Lorenzo
Top achievements
Rank 1
Answers by
Milan
Telerik team
Eduardo Lorenzo
Top achievements
Rank 1
Share this question
or