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

GridView won't refresh when ItemsSource is changed

1 Answer 171 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 06 Sep 2011, 04:21 PM
I have to change the ITemsSource for a gridview when the tab index of a tab item changes, but it is not working.


  index = index - 1;
                            Object g = tcDates.SelectedItem;
                            TabItem ti = (TabItem)g;
                            DateTime selDate = Convert.ToDateTime(ti.Header.ToString());
                             
                            this.dgvProcs.ItemsSource = null;
                             
 
                            IList<Procs> currentList = this.apptProcsVerifs[index].Appointment;
                            this.dgvProcs.ItemsSource = currentList;
                            this.dgvProcs.Rebind();
 
 
 
 
here is the model:
 
public class VerificationApptModel
    {
     public event PropertyChangedEventHandler PropertyChanged;
     private object selectedItem;
     private IList<Procs> _Appt;
     private int _VerificationId;
     private DateTime _ApptDate;   
 
 
     public VerificationApptModel(int verificationID, DateTime apptDate)
     {
         this.VerificationId = verificationID;
         this.ApptDate = apptDate;
          
 
     }
 
 
    
     public IList<Procs> Appointment
    {
        get { return _Appt; }
        set {
            if (_Appt != value)
            {
                _Appt = value;
                OnPropertyChanged(" Appointment");
            }
            }
    }
 
     public int VerificationId
     {
         get { return _VerificationId; }
         set {
             if (value != _VerificationId)
             {
                 _VerificationId = value;
                 OnPropertyChanged("VerificationId");
             }
         }
     }
 
     public DateTime ApptDate
     {
         get { return _ApptDate; }
         set {
             if (value != _ApptDate)
             {
                 _ApptDate = value;
                 OnPropertyChanged("ApptDate");
             }
         }
     }
 
     protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
     {
         PropertyChangedEventHandler handler = this.PropertyChanged;
         if (handler != null)
         {
             handler(this, args);
         }
     }
 
     public object SelectedItem
     {
         get { return this.selectedItem; }
         set
         {
             if (value != this.selectedItem)
             {
                 this.selectedItem = value;
                 this.OnPropertyChanged("SelectedItem");
             }
         }
     }
 
     private void OnPropertyChanged(string propertyName)
     {
         this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
     }
 
    }
 

I'm really stuck.. Please help deadline approaching


here is the grid:

 <telerik:RadGridView Name="grdNextApptInfo"  HorizontalAlignment="Left" Width="550" Height="168" ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                                         AutoGenerateColumns="False"  RowIndicatorVisibility="Collapsed"  ShowGroupPanel="False" IsFilteringAllowed="False"
                                         ScrollViewer.VerticalScrollBarVisibility="Auto" Visibility="Collapsed" Margin="0,0,0,1" IsReadOnly="True" >
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Code" Width="70" DataMemberBinding="{Binding Code}" IsSortable="False"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="Description" Width="70" DataMemberBinding="{Binding Description}" IsSortable="False"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="Creator" Width="80" DataMemberBinding="{Binding LastFirstName}" IsSortable="False"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="CDate" DataMemberBinding="{Binding CreatedDate}" Width="50" IsSortable="False"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="For In" DataMemberBinding="{Binding NextAppt}" Width="70" IsSortable="False"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="Diag1" DataMemberBinding="{Binding Diag1}" Width="40" IsSortable="False"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="Diag2" DataMemberBinding="{Binding Diag2}" Width="40" IsSortable="False"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="Diag3" DataMemberBinding="{Binding Diag3}" Width="40" IsSortable="False"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="Diag4" DataMemberBinding="{Binding Diag4}" Width="40" IsSortable="False"></telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 07 Sep 2011, 08:28 AM
Hi Sean,

In order to suggest any further, I would need some more details. Do you want to have a single instance of RadGridView and reuse it on different tabs ? What is the exact scenario that you want to accomplish? Do you get any errors ? 
 

Regards,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
Sean
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or