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

adding new row programatically

1 Answer 174 Views
GridView
This is a migrated thread and some comments may be shown as answers.
reema
Top achievements
Rank 1
reema asked on 18 Feb 2009, 08:28 AM


hi to all,

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


thanx in advance....

1 Answer, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 19 Feb 2009, 02:33 PM
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.
Tags
GridView
Asked by
reema
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
Share this question
or