Change GridView Row Color Based On Condition In C#

Feb 19, 2011

I want to change a particular row color of gridview based on some condition, i am using ASP.NET with c#.

View 2 Replies

Similar Messages:

SQL Reporting :: Change Font Color Based On Condition?

Dec 10, 2009

I want to change the font color based on condition, I have a field of type "TimeSpan" and i wanted to change the color of that field(textbox). For example is the field value is equal to or more than 5 hours as "05:20:45" then the font color should be "Green" and if the field value is less than 5 hours as "04:12:35" then the font color should be "Red"

View 4 Replies

Forms Data Controls :: How To Change The Color Of The Value In Gridview Using Condition

Jun 17, 2010


if the ABOVE pic is not visible CLICK HERE to view

I want to change the colors of the values from the table SALARY

if the salary is > 20,000 i want to change it to GREEN color

if < 20,000 then it should show RED color

View 4 Replies

Change Gridview Row Color Based On Templatefields Without Controls

Feb 25, 2011

My gridview does not use controls, because it is populated using expressions

<asp:TemplateField HeaderText="As Of Sales">
<FooterStyle Font-Bold="True" />

I want to compare column index 1 and column index 8, and if 8 is bigger then 1 it should be a different font color.

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim x As String
x = e.Row.Cells(1).Text
Dim y As String
y = e.Row.Cells(8).Text
If Convert.ToInt32(x) <= Convert.ToInt32(y) Then
e.Row.ForeColor = System.Drawing.Color.Blue
End If
End If
End Sub

View 1 Replies

Forms Data Controls :: Can Change Gridview Row Value Color Based On Current Date

Mar 15, 2011

I have Jobschedule( different work centers) displaying in grid view on my webform When particular workcenter passes the current date then it should highlight with Red color ,(following sechedule i bolded the dated which are passed current date since i did not find how to make color here)

View 12 Replies

Change Color Of Row Based On Value Of A Column In The Row?

Jan 19, 2011

I have an sqldatasource that loads, data from my server and puts it in a datagrid.

I have a Column named clnumber that has, the numbers 1,2,3

What I want is that each row have a different color depending on which number is in that datarow column



View 4 Replies

Forms Data Controls :: Add Background Color To Gridviewrow According To Condition In Gridview

Jan 10, 2010

i want to add b.colr to gridview row

html code


View 9 Replies

Forms Data Controls :: Change Background Color Based On Data Key Change?

Sep 10, 2010

I have a GridView with an alternating Css style. The GridView has a column called tradeId. What I want to show is an alternating colour based on a change in the tradeId. Is this possible? It will make it easier on the eye to group trades together by colour. Here's the GridView code as it is right now:


View 2 Replies

C# - How To Check The CheckBox In A GridView Based On Condition

Jan 11, 2011

I have four textbox fields for ItemName, ItemDescription, Length and Quantity.

One radiobuttonlist and its listitems are FixedLength and Random Length.

One button field called Submit and one gridview.

In the GridView I have 4 bound columns and 1 template column such as ItemName, ItemDescription, Length, Quantity and IsFixed_f(flag field). I have added one checkbox in the GridView's Template column for the IsFixed_f field.

After entering all textbox fields, I have to select either one listitem in the radiobuttonlist(FixedLength or RandomLength). After completing these things. If I enter the Submit button, all the values in the textbox to be displayed under the GridView's corresponding column name and checkbox to be checked if FixedLength listitem is selected otherwise the checkbox.checked should be false. How to do this?

In the Button Click event, i have used like this


View 3 Replies

Hide A Column Of GridView Based On A Condition?

Feb 11, 2011

I want to hide a column of GridView based on a condition. How can I access the column in C# code?

if() // condition
// Disable code here. ?????

View 2 Replies

Web Forms :: Database Menu - Change Background Color Based On Current Location?

Dec 18, 2009

I am making an website and have decided to use a master page then use a sql database for the website navigation. Now what I wan't to do is when a user is on a page i want the background color of the link to be white. For example if the user was on the home page, the home link in the navigation bar would have a white background.

I would prefer that the code to do this be in C# if at all possible. Oh by the way, i am using a repeater to display the links. Below is the code of the repeater.


View 3 Replies

Forms Data Controls :: Detailview Text Color Change Based On Variable?

Feb 15, 2010

I'm trying to change a row in detailsview based on a value in a coloum. Exactly the same as this example but in Detailsview: [URL]

View 3 Replies

Forms Data Controls :: Hide Gridview Row Based On Condition?

May 10, 2010

I have one gridivew where i have written some code and bind it.. itz working fine now my requirment is when ever any gridview row which conatin column 3rd zero(0) i want to hide tht row ..

View 2 Replies

Forms Data Controls :: How To Display The Images In GridView Based On Certain Condition

Jun 29, 2010

if i give the 10 number,10 number of same images should be diplayd in the Grid View.

how can i do that.

View 7 Replies

Forms Data Controls :: Gridview Detail Based Upon Checkbox Condition

Nov 20, 2009

I have three individual methods of searching for a particular product - a cascading drop down menu system with the final dd being the product ID; an autocomplete text box that a user can search for a product and select and finally, a blank text box where the user simply enters the product ID (note products are all being sourced from the same class using different methods i.e. a page method & a web service method)

Individually, I have no problems in creating a grid view based upon the final product that the user selects i.e. Configure Data Source, amend the where clause so that the source picks up from the one control. My problem lies in that I would like to set up a condition whereby the grid view is populated according to whether either the ddl is populated OR the acTextBox is populated OR the textbox is filled with an ID.

My thinking was to assign a related check box to each of the controls and depending upon which option is check, a button could be used to bring up the appropriate grid view results. What do people think? Is that the best way to do this and if so, how would I go about configuring the datasource to pick up the appropriate data value based upon the check box?

View 3 Replies

Forms Data Controls :: Image Display In Gridview Based On Condition?

Mar 7, 2011

i m displaying an image in gridview based on condition from sql table. That is if the colum named "availabillity" is A the image will be red n if the value is "NA" the image will be green. i am using RowDataBound event.

but i am getting error as "Cannot implicitly convert type 'System.Web.UI.WebControls.DataControlRowType' to 'bool'".

View 7 Replies

Forms Data Controls :: Disable Single Column In The Gridview Based On Some Condition?

Nov 3, 2009

I have a boundcolumn in gridview.The column is being populated from the stored procedure.In the stored procedure there are some calculations being done for populating data in the column.

Now I want to know that is it possible to disable the boundcolumn in server side.

View 6 Replies

Forms Data Controls :: How To Change The Link Button Color Based On The Field Bit Type Data 1 Or 0

May 11, 2010

<asp:LinkButton ID="lblRevision" runat="server" CssClass="Textboxes" Text='<%# DataBinder.Eval(Container.DataItem, "RevNo")%>' CommandName="FileDownloadRecord"></asp:LinkButton>

how to change the linkbutton color based on the DOCID value (another field which is coming via databind) which is 1 or 0 bit type boolean value.

View 2 Replies

Forms Data Controls :: How To Change GridView Row Color When A GridView Row Is Selected

Nov 5, 2009

When an application user selects a particular row in my GridView, I would like to have the row highlighted in a different color. (By selects I mean the mouse cursor was moved into a cell in a GridView row)

I found this article on the web where something similar is done. Basically the row color changes when the mouse cursor hovers over a GridView row. And again changes when the mouse cursor hovers over a different row.

The difference with my approach is that I only want the color to change when a mouse cursor is placed in a gridview cell in a row. And then it won't change color until the cursor is placed in a different row/cell of the GridView. how I can have the row color change only when the row is selected? I tried using the onclick property but that did not work. (See lines 9 and 15 below) e.Row.Attributes.Add("onclick"

1 protected void Gridview1_RowCreated(object sender, GridViewRowEventArgs e)
2 {
3 // only apply changes if its DataRow [code]...

View 2 Replies

Change The Color Of Particular Cell In A Gridview?

Jul 21, 2010

Iam displaying the days of a month in a grid. If the first day of the month starts with Wednesday then I need to gray out the cells of Monday and Tuesday for the first week. Is it possible to change the color of particular cell in a gridview? Iam not using rowdatabound Is there any alternative apart from rowdatabound?

View 2 Replies

Change Color Of Certain Texts In A Gridview?

Feb 23, 2010

I have a gridview that displays data from a DB... Currently I can only change colors of all the texts in a cell, but what I need to do is to change the color of certain texts only. Is there a way to do this?

This is my function for changing color of texts in cells:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
if (_SearchKey != string.Empty)
if (e.Row.RowType == DataControlRowType.DataRow)
for (int ctr = 0; ctr < e.Row.Cells.Count; ctr++)
if (e.Row.Cells[ctr].Text.ToLower().Contains(_SearchKey.ToLower()))
e.Row.Cells[ctr].ForeColor = System.Drawing.Color.Red;

View 1 Replies

Forms Data Controls :: Binding Data With Gridview Based Upon Condition?

Jan 22, 2010

I have a Data Table which Populate from the Stored Procedure which is below


and iam binding the Gridview with Data Table it is working .Now i have to make some thing visible and Invisible based upon some Value like below

Datatable dtTable = (Viewstate)["StatusData"]; // Same Data Table which is Data Source of Gridview Control

Where Status.Open is an integer Enum value like Open = 1 and Close = 2 .row["Status"] is the Text Open and i want to compare with integer valueHow i compare the Values ? i have to use the same Data table or not?

View 2 Replies

Change Gridview Cell Color At Runtime?

Jan 27, 2011

Tried this:


Protected Sub gvCriticalMaterials_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvCriticalMaterials.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
If Trim(e.Row.Cells(7).Text) <> "" And Trim(e.Row.Cells(10).Text) <> "" Then
If Convert.ToDateTime(e.Row.Cells(7).Text) < Convert.ToDateTime(e.Row.Cells(10).Text) Then
e.Row.Cells(7).ForeColor = Drawing.Color.Red
End If
End If
End If
End Sub

But it never shows any value for text in the cells.

View 3 Replies

C# - Change Cell Color On Different Values - Gridview?

Dec 13, 2010

I need to distinguish two consecutive cells, each one in a row, if they have different values, when databindind the values to a gridview.

So, if in the row 1 i have the cell "ABC" and in the row 2 i have the cell "CBA" i need to color each cell with a different color.

View 4 Replies

Gridview - Change The Color Properties Vertically?

Mar 19, 2011

I have a dynamic gridview, about 35 rows by 11 columns. When the user hovers over a row, I highlight the row's background in green (with CSS:Hover).

I would like to change the column's background as well, but I don't think I can assign css to a entire column. How can I accomplish this?

View 1 Replies

Forms Data Controls :: Change Row Color In Gridview?

Oct 6, 2009

I have a grid view where I need to change the row back color based on a ID. The girdview is bound dynamically and it can have any sets of ID. So when two ID are the same the backcolor of the row needs to be the same.

I know I should change the Rowdatabound code but I am not sure how to dynamically change the color. Is there a way to increment color values based on ID's

View 5 Replies

Forms Data Controls :: How To Change Row Color In GridView

Feb 25, 2010

I am developing a scheduling system in which customers are alloted 15 minute timeslots (see example below). During rowdatabound event I know how to change the value of Cell(1) to NULL by using e.Row.Cells(1).Text = "" so Select option is not available for that timeslot. This works fine for someone who has taken only 1 timeslot.

Question is, when a Customer has for example 1:00 hour appointment (which is 4 x 15 minute time slots), how do I make the next 3 rows Cell(1) value NULL?

Is there anything like e.Row+1.Cells(1).Text = "" or some loop that I can run to take care of next few rows?


View 4 Replies

Forms Data Controls :: How To Change GridView Row Color

Jun 1, 2010

I am pretty new to development. I have a a checkbox in template column in gridview how do i change the color of grid row when the check state changes.

View 5 Replies

Forms Data Controls :: GridView Row Color Change?

Dec 13, 2010

i have gridview & m appliying for dis gv paging sorting and row color change respective courses for dat i have written code but after 3 records he give this error

Specified argument was out of the range of valid values.

Parameter name: index my code is


View 5 Replies

Forms Data Controls :: GridView Row Color Change

Dec 31, 2009

I have alternative colors on my gridview white and lightiest green when i am placing mouse over the row color changed to Green when i mouse out of the row color changed to white i did write.Here i need a change when event mouseout occures rows-color fallsbackto original alternative colors i.e white and lightiest green

Private Sub GVData_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onmouseover", " = 'lightgreen';'hand'")

View 6 Replies

Copyrights 2005-15, All rights reserved