.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

WPF Data Grid - set style based on value

Posted By:      Posted Date: September 19, 2010    Points: 0   Category :WPF
Hello All,
I am using a DataGrid and want to set the background of the row to certain color based on value. Example
One of the columns is Time Taken. If the value is less than 5, then no change. If it's between 6 and 10 then yellow and if greater than 10, then red.
I am looking for "OnDataBound" event - don't see any.
I am looking for something like
foreach(Row row in DataGrid1.Rows).... <-- not there.
How do I do it?
I am new to all this...sorry if this looks like a stupid question.

View Complete Post

More Related Resource Links

How to retrive Data from SharePoint List to Data Grid View in Visual WebParts based on the Condition

Hi Friends... 
Here i write this Code for Retrieving Data Form SharePoint List to Data Grid view (st_attendance) in Visual Web parts....  But it doesn't work Properly....

SPWeb web = SPContext.Current.Web;
            SPList list = web.Lists["Student Profile"];
                string caml = string.Format(@"<Where><Eq><FieldRef Name='Academic Year' /><Value Type='Text'>{0}</Value></Eq></Where>",DropDownList2.Text );
                SPQuery query = new SPQuery(list.DefaultView);
                query.Query = caml;
                SPListItemCollection items = list.GetItems(query);
                st_attendence.DataSource = items;
                Controls.Add(st_attendence );

How to retrive Data from SharePoint List to Data Grid View in Visual WebParts based on the Condition

Hello Friends,

I am Srinivas, I want to know the How to retrive the Data from SharePoint List to Data Grid View in Visual WebParts based on the Condition.

Example: I want to retrive Students information from Lists to Grid View based on the Condition(based on 'Academic year' or 'Class' and 'Section'). In Student Status Page Grid view should be show the Student Details in their Status.

please any body help me



How to retrive Data from SharePoint List to Data Grid View in Visual WebParts based on the Condition


Hello Friends,

     I am Ali, I want to know How to retrive the Data from SharePoint List to Data Grid View in Visual WebParts based on the Condition.

Example: I want to retrive Students information from Lists to Grid View based on the Condition(based on 'Academic year' or 'Class' and 'Section').         In Student Status Page Grid view should be show the Student Details in their Status.

please any body help me



How to retrieve Data from SharePoint List to Data Grid View in Visual WebParts based on the Conditi


Hi Friends..

I am Srinivas Devi

I want to retrieve data from SharePoint List to Data Grid View using Visual Web parts. I want know how to write a LINQ query for retrieve data from Share Point List to Grid View based on two or More Conditions.

Like based on Employee Number, Employee Department etc...

Please Help me Sir..

Thank U Sir..



How to get data from table based on four table



I need to know how to show top 30 records from four table

with fastest speed.. in ms sql server 2005..

hope You do the needfull


Beyond ASP: XML and XSL-based Solutions Simplify Your Data Presentation Layer


The combination of XML and XSL can provide a powerful alternative to ASP development. This article presents arguments for building even small-scale Internet applications on the XML model. An example written with traditional ASP programming is compared to the same example written with XML and XSL in order to show the benefits of this approach. The example is followed by nine good reasons to make the switch. These reasons include separation of presentation and data, reusability, extensibility, division of labor, enhanced testing, and legacy integration. The XML/XSL solutions described hold the promise of greater simplicity, flexibility, and durability than ASP solutions built the traditional way.

Scott Howlett and Jeff Dunmall

MSDN Magazine November 2000

Building a Custom Data Grid: Performing Ad Hoc Web Reporting with a VBScript 5.0 Class Object


A flexible, customizable grid for displaying data is a useful tool for ASP developers. It allows Web visitors to customize their view of your data. This article takes the data grid presented in "Ad Hoc Web Reporting with ADO 2.0" by John Papa and Charles Caison (MIND, December 1998) and adds handy features such as a finds feature that supports multiple finds and a mode for adding and editing records. This version also improves response time by allowing asynchronous record download and it componentizes the code so it can be used as a standalone VBScript class object that can be reused in other pages.

Randall Kindig

MSDN Magazine July 2000

show data in grid view error Arithmetic operation resulted in an overflow.



i have a table there is 17 columns in 17 column 3 are number and other are varchar . when i try to display all data of that column error occures.

one more intersting think is when i try to display 6 column then grid show there data an no more error occures. 

when i run my project this error occures in grid view

Arithmetic operation resulted in an overflow. 

Insert data based on gridview user value on row.. how to



I have three column comes from database table(Table1) and one column is for entering data for the user let us consider it look like this 

ItemNo ItemName Qty  uservalue

001       A               50       20

002       A               20       5

003       B               50  

004       C               60      10

005       D               40 

006       E               90      15 


If its 300 row from database to gridview it will show 50 record with page navigation..

What i need is i need to insert data in to database table which gridview row has user value..

The output of the another table(Table2) will look like this after insert

ItemNo ItemName   uservalue

001       A                    20

002       A                      5  

Best practice? Accessing subset of data based on user


I have a DB and associated Asp.net 3.5 web app. The database holds information on our clients. We're adding client access functionality and I need to know how best to restrict user access to data only pertaining to their client.

The clients are stored in a hierarchy and each user can be associated with multiple clients. The user should only be able to access the data for their associated clients and any sub clients thereof.

My initial thought is to add a collection of clients to their profile, then use that to filter all queries; however, my gut instinct tells me that using the profile for such a security function is inadvisable.

Could anyone provide any insight on a best practice for this? I'm sure it must be a pretty common need.


Error when using a style based on another style from an external ResourceDictionary

Hi, I have defined some styles in a ResourceDictionary in a class library. I import this ResourceDictionary in my application: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="MultiTaskingDictionary.xaml"/> <ResourceDictionary Source="pack://application:,,,/Wpf.MVVM;component/Themes/LibResources.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> In the ResourceDictionary I have a style errorStyle and based on this style a style called rightStyle: <Style x:Key="rightStyle" BasedOn="{StaticResource errorStyle}" TargetType="{x:Type Control}"> <Setter Property="Margin" Value="5"/> <Setter Property="Control.HorizontalAlignment" Value="Stretch" /> <Setter Property="Control.VerticalAlignment" Value="Center" /> </Style> <Style x:Key="errorStyle" TargetType="{x:Type Control}"> <!--Some styling stuff....--> </Style> In my application I have a usercontrol with a textbox defined like this: <TextBox Grid.Row="0" Grid.Column="1" Name="textLabel" Styl

Getting filtered data from Role based SSAS security

Hi everyone,I've got a heap of reports that are based on various SSAS cubes. I have roles defined on these cubes that restrict data via certain dimensions. Question is, will these restrictions filter through to the report...ie, if I have a sales person restricted in the SSAS cube to only see sales against their territory (restricted in the Territory dimension), when they run the report will it filter the result based on their SSAS credentials and only show the data they have access to (even though the SSRS report has no direct filters or parameters applied)?Cheers for any help!!

Expand rows in a data grid to show details in the same page

<asp:templatecolumn headertext="Purchase Order"> <headerstyle horizontalalign="center"></headerstyle> <itemstyle horizontalalign="center"></itemstyle> <itemtemplate> <%# DataBinder.Eval(Container.DataItem, "PurchaseOrder") %> </itemtemplate> </asp:templatecolumn> <asp:templatecolumn headertext="Order"> <headerstyle horizontalalign="center"></headerstyle> <itemstyle horizontalalign="center"></itemstyle> <itemtemplate> <a href="OrderDetail.aspx?Order=<%# DataBinder.Eval(Container.DataItem, "OrderNumber")%>"> <%# DataBinder.Eval(Container.DataItem, "OrderNumber") %> </a> </itemtemplate> </asp:templatecolumn> <asp:templatecolumn headertext="Ack Date"> <headerstyle horizontalalign="center"></headerstyle> <itemstyle horizontalalign="center"></itemstyle> <itemtemplate> <%# DataBinder.Eval(Container.DataItem, "AcknowledgeDate") %> </itemtemplate> </asp:templ

Listview Toggle Visibility of a Textbox based on Data Not Null.

I want to toggle a Textbox to be visible (true, false) contained within an InsertItemTemplate based on the data being Null/Empty.   It Works in the Item Template since it is calling the "select parameters", but once it is in the "insert parameters" on databinds, I am unable to get this to work.  <%# String.IsNullOrEmpty(Convert.ToString(Eval("qu_8")))?Convert.ToBoolean("false"):Convert.ToBoolean("true") %> (works in Item Templates, but not in InsertItemTemplate to toggle a textbox to be visible or not visible). I am using C# in code behind. Thanks in advance -Mark

Export Data to Excel Based on Date Range

I have data from multiple tables that I would like to display in a gridview via a stored procedure.  I need to select the data based on a date range and display it.  Once displayed I need to include a button that would allow the user to export the gridview data to an excel spreadsheet.  Does anyone have an out of the box solution or know of a tutorial I can use to accomplish this feat?  I am currently using 2.0 for this project. I am newish to .net. Thanks in advance. Here is my stored procedure that calls the data from multiple tables.USE [DATABASENAME] GO /****** Object: StoredProcedure [dbo].[GetUsersAll] Script Date: 09/03/2010 08:20:23 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[GetUsersAll] AS SELECT aspnet_Users.UserName, aspnet_Membership.Email, Team.Name, MemberTeamRole.InsertDate, MemberTeamRole.ManagerApprovedDate, MemberTeamRole.RegistrarApprovedDate, MemberTeamRole.RoleName, MemberInfo.firstname, MemberInfo.lastname FROM aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId INNER JOIN MemberInfo ON aspnet_Users.UserId = MemberInfo.memberid LEFT OUTER JOIN MemberTeamRole ON aspnet_Membership.UserId = MemberTeamRole

Cannon add new Data Source in Grid in VS2005 using SQL Server2005

I am a student and started out with VS2010 on my laptop.  Due to compatibility issues, I had to start using the provided version, 2005.  I uninstalled 2010 and now have the trial version of VS 2005 as well as SQL Server 2005. I have a data grid on a windows form and am attempting to use a database provided for the class.  When I use the smart tag to start the Wizard, as directed I do the following Select Add Project Data Source Choose Type..Database..Next In Choose Data Source Window, I select New Connection  Data source: MS SQL Server Database File..Continue In Add Connection Window, Data source: SQL Server Database File (SqlClient) Database file name...browse to database file in Student cd (E:\StudentData\DatabaseFilesSQLServerVersion\RnrBooks.mdf) Log on to the server: Use Windows Authentication And then press Test Connection Here is the error that I get: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance.  The connection will be closed  

changing font color on a data column field based on the contents

I am trying to change font color if the datafield has the string EMERGENCY. This is my original template field: <asp:TemplateField HeaderText="Type" SortExpression="DigType"> <EditItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("DigType") %>' ></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("DigType") %>' ></asp:Label> </ItemTemplate> </asp:TemplateField>   and this is what I thought would work: <EditItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("DigType") %>' ForeColor='<%# IIf(Eval("DigType")="EMERGENCY","Black", "Red") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("DigType") %>' ForeColor='<%# IIf(Eval(&quo
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