.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Articles >> Silverlight >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Silverlight Datagrid - Retrieving details on Editing

Posted By:Mahadesh Mahalingappa       Posted Date: August 19, 2011    Points: 200    Category: Silverlight    URL: http://www.dotnetspark.com  

In this article we would be seeing how we are going to retrieve the details on Editing the DataGrid or Listbox.

In this article we would be seeing how we are going to retrieve the details on Editing the DataGrid or Listbox.

Created a new Project SLDatagridClick and

Add a DataModel as shown below to the Web Project.

Add DataModel in silverlight

DataModel Wizard in silverlight

Data Model is created as shown below :

DataModel in silverlight
WCFService in silverlight

Add a method to the DataService as shown below :

public IEnumerable GetPersons()
  DataEntities context = new DataEntities();
  var persons = from o in context.People
  select new Persons
  id = o.ID,
  firstName = o.FirstName,
  lastName = o.LastName
  return persons;
public class Persons
  public int id { get; set; }
  public string firstName { get; set; }
  public string lastName { get; set; }

Add the Service Reference to the Silverlight Project.

Add Service Reference in silverlight

Now lets get into the Silverlight project.

Modify the MainPage.xaml.cs as shown below :

using SLDatagridClick.DataServiceReference;
namespace SLDatagridClick
  public partial class MainPage : UserControl
  public MainPage()
  DataServiceClient client = new DataServiceClient();
  client.GetPersonsCompleted += new EventHandler(client_GetPersonsCompleted);
  void client_GetPersonsCompleted(object sender, GetPersonsCompletedEventArgs e)
  dg.ItemsSource = e.Result;

Now lets give it a run and see the output :

DataGrid Display in silverlight

Now lets get to work. When I Edit the cell , I should be able to retrieve the modified cell contents. I have just tried to bring together some of the scenarios I came across while using Datagrid. In this article I would demonstrate one such scenario :

Lets add the code for that scenario :

Add the event handler :

dg.CellEditEnded += new EventHandler(dg_CellEditEnded);

Make use of the CellEditEnded.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend