Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










Change GridView Row Color Based On Condition In C#


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


View 2 Replies (Posted: Feb 19 at 4:04)

Sponsored Links:

Related Forum Messages For ASP.NET category:
SQL Reporting :: Change Font Color Based On Condition?
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"

Posted: Dec 10, 2009 07:54 AM

View 4 Replies!   View Related
Forms Data Controls :: How To Change The Color Of The Value In Gridview Using Condition
[URL]

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

Posted: Jun 17, 2010 09:20 AM

View 4 Replies!   View Related
Change Gridview Row Color Based On Templatefields Without Controls
My gridview does not use controls, because it is populated using expressions

<asp:TemplateField HeaderText="As Of Sales">
<ItemTemplate>
<%#Getsales(Decimal.Parse(Eval("asofsales").ToString())).ToString("C0")%>
</ItemTemplate>
<FooterTemplate>
<%#Getsales1().ToString("C0")%>
</FooterTemplate>
<FooterStyle Font-Bold="True" />
</asp:TemplateField>

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

Posted: Feb 25 at 22:12

View 1 Replies!   View Related
Forms Data Controls :: Can Change Gridview Row Value Color Based On Current Date
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)

Posted: Mar 15, 2011 09:55 AM

View 12 Replies!   View Related
Change Color Of Row Based On Value Of A Column In The Row?
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

THIS IS THE CODE I USED

[code]....

Posted: Jan 19 at 17:12

View 4 Replies!   View Related
Forms Data Controls :: Add Background Color To Gridviewrow According To Condition In Gridview
i want to add b.colr to gridview row

html code

<div>

Posted: Jan 10, 2010 07:57 PM

View 9 Replies!   View Related
Forms Data Controls :: Change Background Color Based On Data Key Change?
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:

[Code]....

Posted: Sep 10, 2010 10:13 AM

View 2 Replies!   View Related
C# - How To Check The CheckBox In A GridView Based On Condition
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

[code]....

Posted: Jan 11 at 9:26

View 3 Replies!   View Related
Hide A Column Of GridView Based On A Condition?
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. ?????
}

Posted: Feb 11 at 4:27

View 2 Replies!   View Related
Web Forms :: Database Menu - Change Background Color Based On Current Location?
I am making an asp.net 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.

[Code]....

Posted: Dec 18, 2009 02:17 AM

View 3 Replies!   View Related
Forms Data Controls :: Detailview Text Color Change Based On Variable?
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]

Posted: Feb 15, 2010 04:57 PM

View 3 Replies!   View Related
Forms Data Controls :: Hide Gridview Row Based On Condition?
I have one asp.net 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 ..

Posted: May 10, 2010 06:00 PM

View 2 Replies!   View Related
Forms Data Controls :: How To Display The Images In GridView Based On Certain Condition
if i give the 10 number,10 number of same images should be diplayd in the Grid View.

how can i do that.

Posted: Jun 29, 2010 12:42 PM

View 7 Replies!   View Related
Forms Data Controls :: Gridview Detail Based Upon Checkbox Condition
I have three individual methods of searching for a particular product - a cascading drop down menu system with the finalddbeing the product ID; an autocomplete text box that a user can search for a productand 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 methodsi.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 relatedcheck 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?

Posted: Nov 20, 2009 04:07 PM

View 3 Replies!   View Related
Forms Data Controls :: Image Display In Gridview Based On Condition?
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 usingRowDataBound event.

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

Posted: Mar 07, 2011 05:49 AM

View 7 Replies!   View Related
Forms Data Controls :: Disable Single Column In The Gridview Based On Some Condition?
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 inserverside.

Posted: Nov 03, 2009 07:18 PM

View 6 Replies!   View Related
Forms Data Controls :: How To Change The Link Button Color Based On The Field Bit Type Data 1 Or 0
<ItemTemplate>
<asp:LinkButton ID="lblRevision" runat="server" CssClass="Textboxes" Text='<%# DataBinder.Eval(Container.DataItem, "RevNo")%>' CommandName="FileDownloadRecord"></asp:LinkButton>
</ItemTemplate>

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.

Posted: May 11, 2010 05:21 PM

View 2 Replies!   View Related
Forms Data Controls :: How To Change GridView Row Color When A GridView Row Is Selected
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.
http://www.aspdotnetfaq.com/Faq/How-to-correctly-highlight-GridView-rows-on-Mouse-Hover-in-ASP-NET.aspx

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]...

Posted: Nov 05, 2009 02:00 PM

View 2 Replies!   View Related
Change The Color Of Particular Cell In A Gridview?
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?

Posted: Jul 21 10 at 11:17

View 2 Replies!   View Related
Change Color Of Certain Texts In A Gridview?
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;
}
}
}
}
}

Posted: Feb 23 10 at 3:38

View 1 Replies!   View Related
Forms Data Controls :: Binding Data With Gridview Based Upon Condition?
I have a Data Table which Populate from the Stored Procedure which is below

[Code]....

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
[Code]....

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?

Posted: Jan 22, 2010 11:35 AM

View 2 Replies!   View Related
Change Gridview Cell Color At Runtime?
Tried this:

Code:

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.

Posted: Jan 27th, 2011, 12:09 PM

View 3 Replies!   View Related
C# - Change Cell Color On Different Values - Gridview?
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.

Posted: Dec 13 10 at 10:23

View 4 Replies!   View Related
Gridview - Change The Color Properties Vertically?
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?

Posted: Mar 19 at 1:50

View 1 Replies!   View Related
Forms Data Controls :: Change Row Color In Gridview?
I have a grid view where I need to change the rowback color based ona ID. The girdview is bound dynamically and it can have any sets of ID. So when two ID are the same thebackcolorof the row needs to be the same.

Iknow 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

Posted: Oct 06, 2009 04:56 PM

View 5 Replies!   View Related
Forms Data Controls :: How To Change Row Color In GridView
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, whena 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 likee.Row+1.Cells(1).Text = ""or some loop that I can run to take care of next few rows?

[code]....

Posted: Feb 25, 2010 04:01 AM

View 4 Replies!   View Related
Forms Data Controls :: How To Change GridView Row Color
I am pretty new to asp.net 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.

Posted: Jun 01, 2010 06:13 AM

View 5 Replies!   View Related
Forms Data Controls :: GridView Row Color Change?
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

[code]....

Posted: Dec 13, 2010 07:04 AM

View 5 Replies!   View Related
Forms Data Controls :: GridView Row Color Change
I have alternative colors on my gridview white and lightiest green when i am placing mouse over the rowcolor 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-colorfallsbackto 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
GVData.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor = 'lightgreen';this.style.cursor='hand'")
[code]....

Posted: Dec 31, 2009 08:12 AM

View 6 Replies!   View Related
Forms Data Controls :: Change Value's Color By Sql In GridView?
I am retrive data from sql servr (2000) and then binding with GridView. Select Colorname,case when 'red' then '<font color=red>*</font>' When 'green' then '<font color=red>*</font>' end as refernce from colorset. I was expect the gridvew will show difference kind of color in column reference.. But it doesn't... which just shows (assume this is my GridView)

Color name | reference
Red | <font color=red>*</font>
Green | <font color=green>*</font>

I want to show

Color name | reference
Red | * // show a red star
Green | * // show a green star

Posted: Oct 06, 2009 11:06 AM

View 7 Replies!   View Related
Web Forms :: How To Change The Background Color Of A Css Class By Passing A Color Retrieved From A SQL String
I am doing all of the css and theming for our project, and am trying to create an automatic theming convention.

All of the buttons on the site will be using the same css class from the style sheet page. The problem I am having is that the color behind the button depends on the users color in the database. I pull their color from the database and theme the site accordingly.

My question is how can I change the color behind a button, in this case a div object, and set it when the page loads. I know I can set the color on the client's side, but that is only based on the name of the object. Since the buttons are all on different pages, I will not know the name of the button I am using. I am using a Masterpage also.

In the css class I have a class named .buttonBackground. I have a png image set to this button (I say button, but its a div object). I need to be able to change the background color of this image to the color from the DB when the page loads. I thought it would be fairly simple but realized that I do not know the name of the buttons on the current page.

I can change the color onmouseover and onmouseout with JS, but have no idea how to set the color initially.

Posted: Nov 17, 2009 02:13 AM

View 2 Replies!   View Related
Visual Studio :: Background Color Of Web Site / How To Change White Color
i use 1024x768 px to develop web site. When ichange my px to more than 1024x768, i see white color at side of my website.how can i change white color ? how can i use different color ?secondly how can i use instead of color ?

Posted: May 28, 2009 01:43 PM

View 1 Replies!   View Related
Forms Data Controls :: Change Color On Row In Gridview Using Event?
I am trying to change the backgound color on a datarow in a gridview while it is being built by usingan event in the properties of thegridview. I found an example for an integer check but the field I want to check is a text field with the words "STANDARD" OR "SIGNIFICANT" stored in the field within the database. Here is the code I am executing below but I get the error below. (I am including the code I found that does the integer check at the bottom so you can see it as well).

Error 5 Overload resolution failed because no accessible '=' can be called with these arguments: 'Public Shared Operator =(a As String, b As String) As Boolean': Value of type '1-dimensional array of Object' cannot be converted to 'String'.

[Code]....

[Code]....

[Code]....

Posted: Nov 07, 2009 04:48 PM

View 3 Replies!   View Related
Forms Data Controls :: How To Change GridView Row Color On Mouse Over
I am trying to create a Mouse Over for my GridView and have a problem hope any of you can shed some light to how to fix it

Currently my Alternate GridView Row is using this CSS style with an image .mGrid .alt {background:

[code]....

In my GridView I have some codes below, when my mouse move over the Alternate Row I would like to replace theimage Idefined in my css stylesheet with a color but it doesn't work

Protected
Sub GridView1_RowDataBound(ByVal sender
As
Object,
ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs)
Handles GridView1.RowDataBound
If True
Then
If e.Row.RowType = DataControlRowType.DataRow
Then
If e.Row.RowState = DataControlRowState.Alternate
Then
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='lightblue'")
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='transparent'")
Else
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='lightblue'")
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'")
End If
End If
End If

I need to somehow replace the AlternateRowStyle with this.style.backgroundColor of my choice.

Posted: Nov 11, 2009 02:51 PM

View 5 Replies!   View Related
Forms Data Controls :: Change The Row Color Of Some Rows In Gridview?
Iam binding a gridview to a stored procedure. I want to change of some row color based on the data binding.

For example: if "Lesson" =0,change the row color to RED.

[Code]....

Posted: Aug 17, 2010 11:03 AM

View 9 Replies!   View Related
Forms Data Controls :: Change Font Color On Gridview?
i got a gridview to show some records from a database in sql server, two fields in that database are priority and status.

So i want to change the font color in the gridview to those fields.

for example, when the priority is high, show high with font red and when status is new use bond font .

Posted: Oct 22, 2009 09:30 PM

View 6 Replies!   View Related
Forms Data Controls :: How To Change Row Color Manually In Gridview
I m having a gridview and Next and Previous button below gridview. If I click on next, I want to highlight the next row.

If i click on Previous, I want to highlight the previous row.

Posted: Nov 08, 2010 02:24 PM

View 2 Replies!   View Related
Forms Data Controls :: How To Change The Gridview Column Font Color
i have a gridview table and in one column i have this code...

<asp:BoundField DataField="MAIL_READ" HeaderText="VIEW" >

i want to change the font color if the MAIL_READ = 1 (red) and if MAIL_READ is not eq 1 (black)

Posted: Jun 01, 2010 10:27 AM

View 13 Replies!   View Related
Forms Data Controls :: Unable To Change Row Item Color In GridView
I want to change row items colour if last column value of each row >72 therefore I used following code:

[Code]....

The above code is working fine but when I am trying to control row items to the generlized method by the following code, it is working fine but the procedure is not applying successfully for one row which is also meeting criteria:

[Code]....

Posted: Mar 04, 2010 07:02 AM

View 7 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved