adding new row programatically

2 posts, 0 answers
  1. reema
    reema avatar
    30 posts
    Member since:
    Oct 2008

    Posted 18 Feb 2009 Link to this post



    hi to all,

    Is it possible to add new empty row to radgridview  programatically ?
    and if yes how?


    thanx in advance....

  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 19 Feb 2009 Link to this post

    Hi Reema,

    You can see something like this in the RadGrid editing demo here:

    http://demos.telerik.com/silverlight/default.aspx#GridView/Editing

    Otherwise, if your RadGrid is bound to an observable collection, all you would need to do is add a new, empty item of whatever it is to the observablecollection, which will then be reflected in the RadGrid, like this:

    public ObservableCollection<HeaderGroup> gridDataSource = new ObservableCollection<HeaderGroup>();  
     
    public Page2()  
    {  
        InitializeComponent();  
     
        for (int x = 0; x < 5; x++)  
        {  
            HeaderGroup addHeader = new HeaderGroup()  
            {  
                HeaderIdea = "HeaderIdea " + x.ToString(),  
                HeaderName = "HeaderName " + x.ToString(),  
                HeaderType = "HeaderType " + x.ToString()                      
            };  
     
            gridDataSource.Add(addHeader);  
        }  
     
        RadGrid1.ItemsSource = gridHeads;  
    }  
     
    private void AddButton_Click(object sender, RoutedEventArgs e)  
    {  
        HeaderGroup newHeader = new HeaderGroup()  
        {  
            HeaderIdea = ""HeaderName = ""HeaderType = "" 
        };  
     
        gridDataSource.Add(newHeader);  

    Let us know if that works for you.
  3. DevCraft banner
Back to Top