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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

.NET4, DataGrid doesn't apply EditingElementStyle with ValidatesOnExceptions when catching an excep

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :WPF
Hello everyone, I'm using WPF and the .NET 4 framework (4.3.30319), on the Windows 7 32-bit OS. I wanted to keep things simple with validation and my property setter just throws an ArgumentException when the data is not valid, instead of implementing a ValidationRule class. While this worked with a ListBox, it seems it doesn't with a DataGrid. Below is a simple example to reproduce the problem, check the XAML and C# code related to the 2nd column. The datagridTBStyle is meant to apply a specific style when an error occurs (since control templates are out of the question with DataGrid), but what I see is: it applies the correct style when editing the cell (blue text) it doesn't apply the part that is supposed to trigger on Validation.HasError (red on yellow background + tooltip) Without this style, it doesn't apply a red border around the cell as it should according to the documentation. However, it does put a part of red exclamation mark in the row header when an error occurs, and it catches the exception. Am I doing something wrong, or is this actually a bug? Link to the documentation. <Window x:Class="DataGridTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Test" Height="200" Width="350&q

View Complete Post

More Related Resource Links

CROSS APPLY doesn't work in some databases

I've run across a weird error trying to use CROSS APPLY. Running SQL2005SP2 developer edition on XP2 (but same error occurs on Enterprise running on W2K3).A simple CROSS APPLY always works when run from master, but doesn't work when run from most (but not all) of my other user databases. I can't figure out what could be causing the error, or is there some reason it would only work when the current database is master?Here is the simplest testcase I can come up with:select a.spid,b.text from master..sysprocesses a cross apply ::fn_get_sql(a.sql_handle) bIf this is run while the current database is master, it returns spid and SQL without a problem. If it's run in the other SQL-delivered databases (model, msdb, tempb), it also works fine. However, if it's run in all but one of the user databases, I get back an error:Msg 102, Level 15, State 1, Line 1Incorrect syntax near 'a'.I'm stumped on how to troubleshoot this. There is no difference in the query; the only difference is the current database. The databases are all owned by sa. I get the same results with sys.sysprocesses instead of master..sysprocesses.As another datapoint, the employee/department example in the BOL for CROSS APPLY exhibits the same behavior; it works fine if run with master as the current database (regardless of where the tables are created), it fails withMsg 102, Level 15, State 1, Line 3Incorrect synt

Pass DataGrid SelectedCells as CommandParameter doesn't work



I'm using the DataGrid control, and I want to have a command work on several cells the user selected:

<MenuItem Header="Replace with NOP"
          Command="{Binding ReplaceWithNOPCommand}"
          CommandParameter="{Binding ElementName=m_grid, Path=SelectedCells, Converter={StaticResource cellsToMemoryRangeConverter}}">

However, the converter's Convert function is called only once! at the beginning.

If I change the code to :

<MenuItem Header="Replace with NOP"
          Command="{Binding ReplaceWithNOPCommand}"
          CommandParameter="{Binding ElementName=m_grid, Path=CurrentCell, Converter={StaticResource cellsToMemoryRangeConverter}}">

Then the converter gets called each time I invoke the command... and it works ok. But it's not enough since I wanted all the selected cells.

Why is that?
Is there a difference between CurrentCell and Selected cells?

I'm using the PRISM's composite WPF and the MVVM pattern.
I know many ways to workaround this, but I would really like to

Abort() method of wcf client proxy doesn't release session after catching FaultException



I have created a simple wcf service hosted in IIS and wcf client and figured out that when u catch a FaultException from the wcf service and then call client.Abort() to release the session (as the microsoft samples said) it doesn't release the session and hangs up on the 11th call.

Here is example:

Wcf Service:

public interface IService1 
    string GetData(int value); 
public class Service1 : <

Abort() method of wcf client proxy doesn't release session after catching FaultException



I have created a simple wcf service hosted in IIS and wcf client and figured out that when u catch a FaultException from the wcf service and then call client.Abort() to release the session (as the microsoft samples said) it doesn't release the session and hangs up on the 11th call.

Here is example:

Wcf Service:

public interface IService1 
    string GetData(int value); 
public class Service1 : <

Convert to formulas doesn't apply correct filter


I created a pivot table like this:

Image and video hosting by TinyPic

It shows a measure "Nab znesek P" for selected months (attribute Month from Date dimension) - November 2009 and November 2010. There is date hierarchy in the filter where I selected only first 17 days from November 2009 and all 30 days from November 2010. You can see that in the images:

Image and video hosting by TinyPic

Image and video hosting by TinyPic

Then I use "Convert to formulas" option and I get wrong numbers. The result is:

Image and video hosting by TinyPic

The number for 11-2009 is actually a value for the whole month, not just for the selected 17 days. You can see the formula for this cell in the formula bar. Similarly the Grand total value shows the value for all the data (all dates) that exists in the cube.

Is this a bug in excel 2007? It looks like the CUBEVALUE function creates a union between selected dates (cell B3 and A6), instead of intersection.

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.

New Language features in .NET4.0

The site explains the new features and enhancement to VB.NET and C# in .NET framework 4.0. The new enhancements are described in detail with examples and code snippets. One can easily understand the new features from this site. This is a must visit site for every .NET professional.

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:

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.

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.

Using the WPF Toolkit DataGrid

WPF comes with a large number of built in controls, but from the beginning it has lacked something that many application developers find extremely important - a DataGrid. You can use the ListView to create something approximating a DataGrid

A datagrid control that can be personalized... anyone??


Hello all,

I need a datagrid control that has following features, besides other regular stuff like paging, sorting, filtering, etc:

The user should be able to -

1. Select columns to view

2. Select column Sequence

3. Select default sort column

4. Store the setting (as a view) and use it on next visit.

5. llow multiple such views to be stored for a user for future use.

All these settings should be saved and when the user comes back he gets the same settings.

Really appreciate your time and would love to get any ideas.


- Zen

Beginner: this doesn't make sense to me


Do you need and "empty" script tag in the head to run scripts that are in the body?  Also, can you run JQuery scripts if they're in the <head> tag?  The first sample only works if the JQuery script is in the form (and body) tag, not in the head - even if I add $(document).ready(function() { });

This works

<head runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" />
<script type="text/javascript">
<form id="form1" runat="server">
<a href="">Here is a link</a>
<script type="text/javascript">
$('a').click(function () {
alert("you clicked me!");


This doesn't work.  Notice I removed the second <script> tag from the head

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="serve



Dropdownlist Show the all PatientName and save the PatientID in the database and in datagrid showing the PatientID my requirement is that the PatientName show in DataGrid.

how to do ? 

Foundations: Easily Apply Transactions To Services


Managing state and error recovery using transactions is the topic of this month's installment of Foundations.

Juval Lowy

MSDN Magazine January 2009

Unit Testing: Apply Test-Driven Development to your Database Projects


Jamie Laflen extols the benefits of TDD when applied to database development-and supplies some useful techniques along the way.

Jamie Laflen

MSDN Magazine Launch 2008

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