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

Top 5 Contributors of the Month
Post New Web Links

Refresh Silverlight datagrid

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :SharePoint
In a Silverlight page I have a datagrid (items loaded from a SP list) and below it a dataform that lets the user make edits to the items displayed in the datagrid when a row is selected from the datagrid.  However, when a user makes an edit to an item using the dataform, the datagrid doesn’t get refreshed when I re-query (via CAML) the SP list to refresh the datagrid.  Only if I change another item in the dataform, does the datagrid then refresh as expected. Code when I Edit the list item in the dataform: public void EndEdit() { ClientContext context = new ClientContext(ApplicationContext.Current.Url); context.Load(context.Web); _skills = context.Web.Lists.GetByTitle("Skills_NewRequest").GetItemById(skillId); _skills["TimeStamp"] = TimeStamp; _skills["Parent"] = Parent; _skills.Update(); context.ExecuteQueryAsync(OnRequestSucceeded, OnFailListener); } private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args) { Deployment.Current.Dispatcher.BeginInvoke(BindData); } private void BindData() { //MessageBox.Show("Your request has been submitted!"); }   And here’s the code for refreshing the datagrid: private void dataFormNewPending_EditEnding(object sender, DataFormEditEn

View Complete Post

More Related Resource Links

delete more than one row in datagrid in silverlight 3

I tried to delete more than one row in datagird in silverlight, using chechbox checked, and binding to itemsource. I have following code: ---------------------- Orderlist = (System.Collections.ObjectModel.ObservableCollection<SilverlightWebService.Order>)dgOrders.ItemsSource;  System.Collections.ObjectModel.ObservableCollection<SilverlightWebService.Order> orderlist1 = new System.Collections.ObjectModel.ObservableCollection<ConcourseSilverlight.SilverlightWebService.Order>(); foreach (SilverlightWebService.Order aorder in Orderlist) { if (aorder.CheckedItem == false) orderlist1.Add(aorder); }  dgOrders.ItemsSource = orderlist1; -------------- DataGrid will be repopulated. But values selected will be defaut ones, that means data selected is not retained. may be itemsource is changes. how can I resolve this        

Refresh of datagrid


Hi. I have a strange problem.

I am developing on SQL 2008 but deploying to SQL 2005. I need to return a UNION query to the client.

After a couple of hours of debugging I have come to the conclusion that the union query doesn't like running on the SQL 2005 version. When I run the following

dbx.Refresh(System.Data.Objects.RefreshMode.ClientWins, obList)

I get the following error (Which has limited hits on google)

{"The refresh attempt has failed because an unexpected entity was returned by the data source."}

It works fine on the SQL 2008 local version.

It works fine when I remove the UNION and only have one straight forward VIEW

Strange one, and one that may be a block for me.

In hope of a solution or at least some pointers would be gratefully accepted

Many thanks Scott

WPF DataGrid.Items.Refresh Exception


I am getting this exception when calling the Refresh method of a datagrid.items.  Any clue how to solve this?

This is the message:  'Refresh' is not allowed during an AddNew or EditItem transaction


Cannot Automatically Refresh WPF Datagrid (MVVM / Prism)


I'm developing MVVM application. I bind the DataGrid ItemsSource to a ObservableCollection in the ViewModel code. Every user control (eg. TextBox, Label, etc) in the UI except the DataGrid works fine. When the PropertyChanged event is fired, the value is displayed correctly. But not in the DataGrid, I use TwoWay mode, but it seems that the DataGrid never refresh itself. The DataGrid content is refreshed only when I try to sort any DataGrid column.


public ObservableCollection<CartItem> Cart
	get	{
		return cart;
	set	{
		cart = value;
public ObservableCollection<CartItem> cart;

public CartItem CurrentCartItem
	get	{
		return currentCartItem;
	set	{
		currentCartItem = value;
		// Update the Price value programatically, 
		// It works fine when this value is bound to a common control such as TextBlock
		currentCartItem.Price = CurrentCartItem.Quantity * CurrentCartItem.PricePerUnit;

WPF DataGrid Style Templates to make it look like the Silverlight DataGrid



Many of you might have noticed that the WPF DataGrid looks very blah compared to the Silverlight DataGrid.

Here are the WPF DataGrid Screenshot and Silverlight DataGrid Screenshot.

See how in the Silverlight DataGrid the lines are better, there are alternating row backgrounds and the selected row also looks better.

I am surprised the WPF DataGrid doesn't use the same styles by default as the Silverlight.

Has anyone styles the WPF DataGrid to make it look like the Silverlight DataGrid and if so can you share the templates with me?

Or is there a built-in theme in WPF DataGrid that looks close to the Silverlight DataGrid?



Silverlight - Dynamically generating a table for datagrid


Hi there,


I am parsing a table in my Silverlight application. Lets say the table is as follows

*   A   B   C

A   1   2   3

B   3   4   6

C   2   2  2

I do not know before hand the column names, how many columns there are so, as far as I know, I can only see a solution to presenting this as a table with the traditional unbound data strategy as in windows forms.  However, my solution is in Silverlight, so I necessarely need to bind to an object.  But as said, I do not know the object properties, so I got stuck.  Please help; this seems like it should be very simple to display a parsed table.


Many thanks. 


Selecting One Checkbox Control In DataGrid Control Using MVVM Using Silverlight

In this post I will show you how to select single check-box control when you have single check-box control in each row of the datagrid control. As you all know that check-box controls are normally used for the multiple selection and radio buttons are used for single selection. But there are sometimes requirement that control should be check-box and selection should be single. Mean if user view data in the datagrid control then he/she should only select one check-box at a time not more then one. Main page is shown in the Image 1. Here you can see that I have placed check-box control in the first column of the datagrid control which I have also highlighted.

Get SelectedItems From DataGrid Using MVVM In Silverlight

In this post what I want to learn and to share something like how to get the selected items from the data grid control of the Silver light using MVVM. You can see the main output of the example code in the Image 1, here you can see that I have a data grid control and three button with label Add, edit and delete records. Let me explain you what is happening in the example code, user is allowed to select multiple record from the grid and the selected records Ids are displayed in the "Selected Ids" area. If user select only one record then add and edit buttons are enabled and if records are more then one then add and edit buttons are disabled. Similarly If number of selected item count is shown in the delete button text.

How To Use DataTriggers In Silverlight DataGrid

In this short post I will show you how you can use DataTriggers in datagrid control DataGridTemplateColumn. This was one of the questions when reading one of the forum to change persform some sort of functionality depending on the value of the property. Out of the example code can be seen in the Image 1 here you can see that I have used the DataTrigger for the Subscribed which is nullable Boolean type, mean It hold true , false and null value.

Serving Silverlight Apps from Windows Mobile

Even if mobile dev is not my every day work, thanks to the .Net Compact Framework, it's still .Net programming.

Here is the scenario:

You come back home, you have a windows mobile phone wifi capable and you want to quickly get access to your phone pictures from your home network.
You just activate the Wifi, run my app and then browse to the provided link from any computer on the network.

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

Use Jquery with repeater, gridview, datagrid

Before we talk about jquery inside any itemtemplate (repeater, gridview, datagrid), we need to understand the basic use of jquery functions

ListBox tricky to set in a DataGrid/GridView

Listboxes are very tricky to set selected items in grid - there is no real nice way to do it. It would have been great if Microsoft included a property that accepts an array or comma separated values - or anything! But they only allow each item in the list to be selected individually. The way to do this in a grid is a bit messy, but it is fairly simple to implement. When a row is created (as per the event), select the items of the listbox as per the datagrid source data:

Building a 3-Tier App with Silverlight 3, .NET RIA Services, and Azure Table Storage

Silverlight 3, .NET RIA Services, and Windows Azure Services Platform makes a 3-tier Cloud application easier to build: Silverlight 3 as presentation tier, .NET RIA services as the business logic and data access tier, and Windows Azure Table as the data storage tier. The sample application in this article demonstrates the architecture with a simple Survey application with all these technologies working together from Windows Azure.

How to highlight datagrid or GridView row on mouse over?

This article will show how you can Ajax with GridView to display popup messages when mouse moves over certain column. In the demo project I have added first column as an image column with a help icon in it. This kind of implements a feature that if you want more information about the row you can move mouse over this icon, a asynchronous request is sent to server for data about that row and when call returns the returned message is show as a popup message.

Silverlight Simple Animation

Silverlight has several built in techniques for animating controls. Many of these technologies are particularly useful for creating simple animations meant to decorate a web page with eye catching movement that draws the reader's attention. In this post I will skip over these decorative technologies, and instead show how to create a simple animation using a technique similar to those used in many games.

Multiple Column Dropdownlist for the ASP.NET DataGrid

Based on my previous control "Multiple Column DropDownList for ASP.NET", I received many emails asking for the same control to be used in the DataGrid for web applications. Here we go.. This control can be used as the regular MS DropDownList in the DataGrid and also as a regular dropdownlist. It has all the properties, like DataTextField, DataValueField, DataSource, SelectedIndex etc. The download file contains the samples both in VB.NET and C#. In this sample, I have used the Northwind database of SQL Server.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

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