Referencing Dynamically Created GridView

6 posts, 0 answers
  1. Eduardo Lorenzo
    Eduardo Lorenzo avatar
    7 posts
    Member since:
    Mar 2010

    Posted 22 Apr 2010 Link to this post

    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!



  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 22 Apr 2010 Link to this post

    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.
  3. DevCraft banner
  4. Eduardo Lorenzo
    Eduardo Lorenzo avatar
    7 posts
    Member since:
    Mar 2010

    Posted 22 Apr 2010 Link to this post

    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
  5. Eduardo Lorenzo
    Eduardo Lorenzo avatar
    7 posts
    Member since:
    Mar 2010

    Posted 22 Apr 2010 Link to this post

    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?
  6. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 28 Apr 2010 Link to this post

    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.
  7. Eduardo Lorenzo
    Eduardo Lorenzo avatar
    7 posts
    Member since:
    Mar 2010

    Posted 28 Apr 2010 Link to this post

    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
Back to Top
DevCraft banner