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


Advertisements:










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


View 1 Replies (Posted: Feb 25 at 22:12)

Sponsored Links:

Related Forum Messages For ASP.NET category:
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 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#.

Posted: Feb 19 at 4:04

View 2 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
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
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
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 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
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 :: 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
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 :: 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
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
Forms Data Controls :: Change Background Color Of GridView Cell
I've a GridView inside a user control which is used an ASP.NET web part. In the RowDataBound event, I set the background color of cell to yellow or red depending upon a condition. My problem is that the background color doesn't seem to beset properly - the entire cell backgound is not entirely yellow or red. I guess either the GridView sytles, themes or web part zone styles take precedence. How to change background color nonetheless?

Posted: Dec 15, 2009 11:02 PM

View 3 Replies!   View Related
Forms Data Controls :: How To Change Color Of Inner Lines In Datagrid / Gridview
This seems like a simple thing, but I can't find how to do it -- change the color of the "inner lines" (vertical lines or horizontal lines) that appear when Gridlines does not equal "none".

If you set BorderColor, it sets the color of the outer border around the datagrid. The inner lines remain white (or some very light color) and I can't figure out how to change them.

Posted: Apr 27, 2006 07:29 PM

View 8 Replies!   View Related
Forms Data Controls :: Change Gridview Row Color With Any Selection Made?
I have Edit / Delete /Select buttons enabled on my gridview.. Originally i had added the code to change the BackColor when you made a selection.

But now as the edit and delete functions are being completed.. i need to enable that coloring regardless which linkbutton you select.. As long as somethingon that row is selected, then ineed to change it.

I have this within my SelectedIndexChanged event

[Code]....

Posted: Dec 30, 2010 10:16 PM

View 6 Replies!   View Related
Forms Data Controls :: Change Color Of Cell In A Gridview Control?
I am using a gridview control, and would like to change the backcolor of a cell based on the data that is loaded. (I am using VS 2008, framework 3.5), but I am not use how to access that property at runtime.

Posted: Sep 23, 2009 07:48 PM

View 2 Replies!   View Related
Forms Data Controls :: Compare Two Datatable And Change GridView Row Color?
I havea datatable, use it to bind girdview. In may datatable I have customerinformation, name, surname etc.

In other table, I take thesome customer name and surname.

I want to compare thatdatatable andfind the same name, I want tochange row of color.

Posted: Nov 22, 2009 09:35 AM

View 2 Replies!   View Related
Forms Data Controls :: Change The Color In Only Some Chars In A Gridview Cell?
How would I change the color in only some chars in a gridview cell? If a user searched on "ort" and the text was "Tort", I would want only the "ort" to be red and the "T" normal black.

Posted: Oct 05, 2009 03:12 PM

View 6 Replies!   View Related
Forms Data Controls :: Change Color Of Link Button In Gridview?
i am using one gridview with linkbutton when i click the linkbutton it should sending a mail to respective email id , i write sending
mail method and called at onCommand of link button in the gridview. it is working fine, my problem when i successfully a mail is sended
then clicked linkbutton should change the color that indicates that mail are sended.

Posted: Feb 17, 2011 09:17 AM

View 5 Replies!   View Related
Forms Data Controls :: Change Gridview Color On Expired Date?
i want to change color of gridview row to red ,if user login period is expired .

i am doing this:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
ViewState["expdatex"] = DateTime.Now.ToString("MM/dd/yyyy");
if (e.Row.RowType == DataControlRowType.DataRow)

[Code]....

but it is changed all the cells color.

Posted: Jan 09, 2011 07:56 AM

View 5 Replies!   View Related
Forms Data Controls :: Change Grid Lines Color (to Blue) In GridView
How can i change gridlines to blue? ive tried this...

CellPadding="1" CellSpacing="1"

Posted: Oct 12, 2009 03:48 PM

View 3 Replies!   View Related
Forms Data Controls :: Change The Color Of Label Control Inside Gridview?
i am saving color as a string in database

i have a gridview control

[Code]....

i need when this control bindes i want to change the color of label control ,

Posted: Sep 21, 2010 12:19 PM

View 5 Replies!   View Related
Forms Data Controls :: Change The Color Of Disabled Link Button In Gridview
how to change the color of disabled link button in gridview?..

Posted: Sep 21, 2010 09:04 AM

View 7 Replies!   View Related
Forms Data Controls :: Change Gridview Controls Back Color On Mouse Click And Move
i have this on my gridview RowDataBound method. and my grid view has BoundFields which i use to display data, it is always on insert mode. i wand and edit mode. i want the bound textbox fields to change colour on onmouseover and on select to match the entire row colour background as i have specify on d code below. how do i do that? i knw how to change everything bt dnt knw how to oldy change the selected row and changing it only on onmouseover n select. the only thing i wanna change is d controls backcolour

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#DDDDDD'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle");
e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
}

Posted: Jul 14, 2010 09:58 AM

View 10 Replies!   View Related
Forms Data Controls :: Change Height,width,color In Boundfield Of Gridview On Markup?
I was hoping this is simple but i have problems.

Basically i was only able to set the string color with itemstyle-Forecolor.

But how do i set the background of a column and also set height,width.Ok height may not work because i have an itemtemplate with predefined height.

Can this be done in a simple boundfield or must i have all my datafields in itemtemplates?

What i do for one column:

[Code]....

Posted: Mar 11, 2010 02:28 AM

View 18 Replies!   View Related
Forms Data Controls :: How To Change Gridview Hyperlinkfield Column Font Color On Row Mouseover?
I am using gridview for show my data. in gridview i am using hyperlinkfield,i want to change font color on row mouse over please tell me how can its possible.if its not possible,i am ready to use temlate field. pleasegive me solution for my query.

Posted: Sep 18, 2008 03:27 AM

View 10 Replies!   View Related
Forms Data Controls :: Adding Rows To GridView With TemplateFields
I have a GridView for adding Items. I have been adding items from a panel which adds, one at a time, each record of this GV. I want to handle the insertion of these records from the GV. My current code is as follows:

HTML

[Code]....

I don't know how to establish the DataTable to be this GridView's DataSource. I have this for my DataTable:

[Code]....

How can I add rows with the values I choose in the rows in my GV. I would also like to fill this GV, from a DataTable containing records from the database, if the user chooses to, and be able to add new records following the same pattern as before. My DropDownList fills from another DataTable, I'm having no problem filling it and showing it in the current row in the GV. I tried to insert this row programatically to my DataTable:

[Code]....

And I received the following error:

System.IndexOutOfRangeException was unhandled by user code
Message="Cannot Find Column 0."
Source="System.Data"
StackTrace:
en System.Data.DataColumnCollection.get_Item(Int32 index)
en System.Data.DataRow.set_Item(Int32 columnIndex, Object value)
en vtas_frmAnticipo.btnAddItem_Click(Object sender, EventArgs e) en C:sales.aspx.vb:line 194
en System.Web.UI.WebControls.Button.OnClick(EventArgs e)
en System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
en System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
en System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
en System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
en System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Posted: Dec 15, 2009 11:21 PM

View 4 Replies!   View Related
Forms Data Controls :: Programmatically Adding TemplateFields To A GridView?
found lot's of examples out there about TemplateFields in the page markup. But i need to create them in Code. I have already found a few tuts about a class implementing ITemplate, but i don't really get behind this.

I have the following situation :

I haveDataTablea in my code which i fill on a button press (via OracleConnection & OracleDataAdapter). After filling it i add a few custom Columns and then bind the DataTable to the GridView.

The GridView shall be partially editable. Thus it has a few BoundFields that will be read-only. Now i'm trying to add TemplateFields for 3 columns. Those should have a Label in Normal-Mode and a DropDownList in Edit Mode with predefined list items. After edit, the new value should be stored in theDataTable (Can i serialize DataTables to store them in ViewState? Or how can i track the changes asi don't want to update the database until the user clicks "OK").

how i instantiate the dropdownlist in edit mode and how to databind them?

Posted: Nov 19, 2009 09:13 AM

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