0
votes

hey iam doin silvelright 4 app.

I have datagrid with 3 coloums say Name,Age,EmpId,

The datagrid is not binded to itemsource.(Will have no rows intially)

The user can add new rows and finally save the grid on a button click. At the moment of button click i need to get all data from the datatgrid and pass to WCF..

Is it possible to assign datagrid empty itemsource?if so how?

how do i store these data from datagrid.. collections or datatable??

Could someone help me out ..i am new to this.. please provide example if possible.

1

1 Answers

0
votes

(sorry for my bad english)

You have to bind your datagrid to the collection using ItemsSource. Trust me, it will be easier.

Create a class like this:

public class Person
{
    public string Name {get;set;}
    public int Age {get;set;}
    public int EmpId {get;set;}
}

Then, create a ObservableCollection<Person> and bind it to your dataGrid ItemsSource. On a button click, add the code:

myObservableCollection.Add(new Person() { });

this will add a empty row on your grid so you can fill it with some data.

This way you will have a observableCollection with all your data displayed on a dataGrid. You could process/serialize it and send to the server. If you have a specific question about that I suggest you create another question. RIA Services could do this kind of thing easily.