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


Similar Messages:

Web Forms :: How To Change Calendar Component's Header & Dayheader Texts In Code

Jan 19, 2011

Anyone know if it is possible to change Calendar component's header & dayheader texts in code?

I know it is possible with pages LCID setting but can it be done manually?

Reason i need to do this is that i have translation functionality in page and i'd like the calendar to be able translate headers same way. I dont want to change the pages LCID with evry language as i want to keep number and day formats same with all languages.

View 1 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

How To Change Color Of Gridview Row Which Are Edited

Jul 21, 2012

I am trying to change gridview color row permanently which are edited.. In My GV i have 4 columns like workid, name, dob, place.

When user Edits these items I m storing Edited workid with boolean value in separate table called editeditems..  i used below code to change color in row data bound.. but its changing color of all rows Gv

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
if (e.Row.RowType == DataControlRowType.DataRow) {
DataRowView row = (DataRowView)e.Row.DataItem;
if (Session["ordid"].ToString() != "") {
string ordid = Session["ordid"].ToString();

[Code] .....

View 1 Replies

Change Gridview Cell Color At Runtime?

Jan 27, 2011

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.

View 3 Replies

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

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 :: 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?

[code]....

View 4 Replies

Forms Data Controls :: How To Change GridView Row Color

Jun 1, 2010

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.

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

[code]....

View 5 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">
<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

Change GridView Sort Link From Blue To Different Color

May 24, 2014

Tried this:

<HeaderStyle CssClass="headerstyle" />

And in the css:

.headerstyle a{
text-decoration:none;
color:#7dad4a;
display:block;
}

But nothing...

View 4 Replies

Data Controls :: How To Change Color Of CommandField In GridView

May 7, 2015

I used commandfield in gridview that users can update their data in gridview Below is code:

<asp:CommandField EditText = "EDIT" UpdateText = "Update" CancelText = "Cancel" ShowEditButton="True" ItemStyle-Width="45px" ButtonType="Link" ControlStyle-CssClass="linkGVE" />

and css:

.linkGVE
{
text-decoration:none;
color:#02ca02;
text-align:center; }

Here this css if for all EditText and UpdateText and CancelText 

But I want EditText has blue color  and CancelText has red color how I can do it?

View 1 Replies

Data Controls :: Change Color Of GridLines In GridView?

Aug 30, 2013

how to change the color of gridlines?

I tried 2 codes but its not working:-

protected void MyGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
foreach (TableCell tc in e.Row.Cells)
{
tc.Attributes["style"] = "border-color: #c3cecc";
}
}

and

protected void Page_Load(object sender, EventArgs e)
{
this.MyGrid.Attributes.Add("bordercolor", "c3cecc");
}

View 1 Replies

Data Controls :: Change Background Color Of GridView Row

May 7, 2015

How Coloring cells and rows in a Gridview using javascript with these examples of this page. url...

View 1 Replies

Data Controls :: Change Color Of Particular GridView Row On Some Condition?

Nov 27, 2013

There is a gridview, in that i have 5 columns. Data is coming from Database inside gridview.

I want to change the ForeColor of 5th column's particular rows in gridview according to condition.

The data in 5th column is coming from Database. I want to change the ForeColor of that column's particular rows according to condition.

here is gridview data:-

Station Name
State
Gate1
Gate2

[Code].....

I want to change the color of 5th column("DangerValue") rows only according to condition.

View 1 Replies

Data Controls :: Change GridLines Color Of GridView

Mar 15, 2014

I use gridview in my page below is code

<asp:GridView ID="GridView2" runat="server"
AutoGenerateColumns = "false" Font-Names ="Tahoma"
AllowPaging ="true"
OnPageIndexChanging = "OnPaging" PagerStyle-CssClass = "GridPager" PagerSettings-Mode="NumericFirstLast"
BorderColor="#02ca02" BorderStyle="Solid" BorderWidth="1px" RowStyle-BorderColor="#02ca02"
RowStyle-BorderStyle="Solid" RowStyle-BorderWidth="1px"
AlternatingRowStyle-BackColor = "#C0C0C0" ShowHeader="False" GridLines="both">

Here I put gridlines="both" and bordercolor="#02ca02" 

In chrome it shows color of gridview's border correctly but in firefox it shows  gridviews border in black color....

View 1 Replies

Web Forms :: Change Color Of Visited Links In Gridview

May 19, 2012

I want to change anchor link color in gridview once i click that link.

View 1 Replies

Data Controls :: Change Background Color Of Gridview

Apr 9, 2014

how to change backcolor of gridview In ModalPopupExtender

View 1 Replies

Forms Data Controls :: Change The Row Color Of Some Rows In Gridview?

Aug 17, 2010

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

View 9 Replies

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

Jun 17, 2010

[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

View 4 Replies

Forms Data Controls :: How To Change Row Color Manually In Gridview

Nov 8, 2010

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.

View 2 Replies

VS 2010 - Change Row Back Color In GridView Based On Value In Each Row Second Cell

Sep 14, 2011

I need to be able to change a row's back color in the GridView based on the value in each row's second cell.

But, I'm having some trouble looping through each row. I thought the following might work:

VB.NET Code:
For Each gvi As GridViewRow In Me.gvTechPPE.Rows           
ClientScript.RegisterStartupScript(Me.GetType(), "New Entry", "alert ('" & gvi.Cells(1).Text & "')", True)        Next

I ran that just as a test. An alert pops up, but only for the first item in the GridView. All the others are skipped.

View 8 Replies

Data Controls :: Change GridView Row Color Based On Condition

Jul 26, 2013

I want to change the color of particular gridview rows with an image in one row, based on condtion. How to achieve it.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved