Change Color of a cell

I hav one question please.. I want to color a particular cell in a datagrid dynamically..how this can be done?? 


Regards,
Punithkumar
0
Punithkumar
12/18/2007 2:37:39 PM
asp.net.faq 380 articles. 0 followers. Follow

59 Replies
767 Views

Similar Articles

[PageSpeed] 58

http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q745q 

0
novice_dlh
12/19/2007 12:46:24 AM

Hi,

In RowDataBound event of GridView, you can do that.

like this,

  protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].BackColor = System.Drawing.Color.Gray;
        }
    }

Same can do with datagrid in Item databound event.

Hope this helps you.

Regards,

Mustakim Mansuri 


Regards,

Mustakim Mansuri (MCTS, MCPD)
Cybage Software Pvt. Ltd.
0
mustakim
12/19/2007 4:59:55 AM

 Hi,

try the below one...

 Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        GridView1.SelectedRow.Cells(4).BackColor = Drawing.Color.Red
    End Sub


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 5:26:23 AM

I hav one question please.. I want to color a particular cell in a datagrid dynamically..how this can be done?? 

i  have written the code in Button_Click event.

I am creating the datagrid dynamically like this.

DataGrid dgGrid1 = new DataGrid();


Regards,
Punithkumar
0
Punithkumar
12/19/2007 5:41:01 AM

Thank u very much..

But if i use  DataGrid how this can be done..

i  have written the code in Button_Click event.

I am creating the datagrid dynamically like this.

DataGrid dgGrid1 = new DataGrid();


Regards,
Punithkumar
0
Punithkumar
12/19/2007 5:44:18 AM

Hi,

try the below one....

Protected Void Button1_Click()....

{

    Datagrid gd  = new Datagrid();

    gd = Page.FindControl("You dynamically created datagrid Id");

     gd.SelectedItem.Cells(0).BackColor = Drawing.Color.Black


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 6:00:29 AM

 dgGrid1.SelectedItem.Cells[1].BackColor= System.Drawing.Color.Brown;


I tried like this,But it is showing an error like this

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.


Regards,
Punithkumar
0
Punithkumar
12/19/2007 6:00:36 AM

 Hi,

try this post...

http://forums.asp.net/p/1195942/2067489.aspx#2067489 


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 6:03:48 AM

 

I am getting an error like this in the following line..

dgGrid1=Page.FindControl("dgrid1ID");

 Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.DataGrid'


Regards,
Punithkumar
0
Punithkumar
12/19/2007 6:25:51 AM

 Hi,

sorry I missed conversion...

try this... 

 dgGrid1= (Datagrid) Page.FindControl("dgrid1ID");


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 6:27:28 AM

:-(

Im getting same error like this..After doing that also..

Object reference not set to an instance of an object.

in the line

dgGrid1.SelectedItem.Cells[1].BackColor= System.Drawing.Color.Brown;


Regards,
Punithkumar
0
Punithkumar
12/19/2007 6:32:48 AM

 Hi,

post you full code...

if you are creating dynamic controls means, you need to create the controls on every post back... then only the controls will be available. other wise the null reference will occur...

post you full code...


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 6:35:24 AM

private void Button17_Click(object sender, System.EventArgs e)
{

 System.IO.StringWriter tw = new System.IO.StringWriter();
 System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);

 DataGrid dgGrid1 = new DataGrid();

 dgGrid1.ID="dgrid1";
   
 string weeknum=Convert.ToString(DropDownList1.SelectedValue);
 string year=Convert.ToString(DropDownList2.SelectedValue);

 int a = Convert.ToInt16(weeknum);
 int b = Convert.ToInt16(year);

 hw.WriteLine("<p align=center><b><font size='2' face='tahoma' color='black'>Content Technology Services-EMEA</b></font></p>");

 dgGrid1.AutoGenerateColumns=false;
 dgGrid1.HeaderStyle.VerticalAlign=VerticalAlign.Middle;
 dgGrid1.HeaderStyle.HorizontalAlign=HorizontalAlign.Center;
 dgGrid1.ItemStyle.VerticalAlign=VerticalAlign.Middle;
 dgGrid1.ItemStyle.HorizontalAlign=HorizontalAlign.Center;
 dgGrid1.HeaderStyle.Height=32;
 dgGrid1.HeaderStyle.Font.Name="verdana";
 dgGrid1.HeaderStyle.Font.Size=8;
 dgGrid1.ItemStyle.Font.Name="verdana";
 dgGrid1.ItemStyle.Font.Size=8;
 dgGrid1.CellPadding=10;
 dgGrid1.CellSpacing=0;

 BoundColumn bc1=new BoundColumn();
 bc1.DataField="slno";
 bc1.HeaderText="SLNO.";
 dgGrid1.Columns.Add(bc1);

 BoundColumn bc2=new BoundColumn();
 bc2.DataField="Category";
 bc2.HeaderText="Category";
 bc2.HeaderStyle.Width=250;
 bc2.ItemStyle.Width=250;
 dgGrid1.Columns.Add(bc2);

 

 

 string SQL12 = "select * from tblEMEASummary where Week_num=@weeknum AND Year_num=@yearnum AND (RegionType='EMEA/AMERS') AND ReportType like 'contentservicedesk%'";
 SqlCommand cmd12 = new SqlCommand(SQL12,con1);
 cmd12.Parameters.Add("@weeknum",a);
 cmd12.Parameters.Add("@yearnum",b);
 con1.Open();
 SqlDataReader reader12 = cmd12.ExecuteReader();
   
 if(reader12.Read())
 {
  if(reader12["Category"].ToString().Equals("Priority 1"))
  {
   
   dgGrid1=(DataGrid)Page.FindControl("dgrid1");
   dgGrid1.SelectedItem.Cells[1].BackColor= System.Drawing.Color.Brown;
    
  }
 }

dgGrid1.DataBind();

dgGrid1.HeaderStyle.Font.Bold =
true;

dgGrid1.RenderControl(hw);

   
 con1.Close();

Response.ContentType = "application/vnd.ms-excel";

Response.AddHeader("content-disposition", "attachment;filename=RequestPhoneID.xls");

this.EnableViewState = false;

Response.Write(tw.ToString());

 

Response.End();

}


Regards,
Punithkumar
0
Punithkumar
12/19/2007 6:48:06 AM

Actually i am Exporting the contents in to EXCEL sheet.

 


Regards,
Punithkumar
0
Punithkumar
12/19/2007 6:57:57 AM

 Hi punit,

from your code, its looks that find control is not necessary... 

Punithkumar:
dgGrid1=(DataGrid)Page.FindControl("dgrid1");

and you need to set the selected index property of the grid... 

  if(reader12["Category"].ToString().Equals("Priority 1"))
  {
   
   dgGrid1=(DataGrid)Page.FindControl("dgrid1"); //Remove this line

   dgGrdi1.SelectedIndex = Rownumber which to be selected; //Add this line
   dgGrid1.SelectedItem.Cells[1].BackColor= System.Drawing.Color.Brown;
    
  }

 


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 6:58:14 AM

Thank U very much Sir..

After adding that line it is working...

Thanks a lot..Thank u..Big Smile


Regards,
Punithkumar
0
Punithkumar
12/19/2007 7:05:27 AM

 Hi punith,

welcome.. please mark as answer which post helps you.... so it will be helpful to others. 


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 7:08:19 AM

Ya Ok :-)

Thank You..


Regards,
Punithkumar
0
Punithkumar
12/19/2007 7:14:29 AM

 

try color change on gridview  SelectedIndexChange event

 

0
Gulcheen
12/19/2007 7:35:04 AM

 SLA vs Actuals - Content Service Desk (Editorial)

Hii, 

How can i do the above design in HTML without using a table....


Regards,
Punithkumar
0
Punithkumar
12/19/2007 11:28:24 AM

this is not working.. 

<p bgcolor='Red' align=left><b><font size='2' face='verdana' color='black'>SLA vs Actuals - Content Technology Services</b></font></p>


Regards,
Punithkumar
0
Punithkumar
12/19/2007 11:31:56 AM

 Hi,

try this...

<p style="background-color:Red;" align=left><b><font size='2' face='verdana' color='black'>SLA vs Actuals - Content Technology Services</font></b></p> 


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 11:47:31 AM

Im using like this.. 

hw.WriteLine("<p align=center><b><font size='2' face='tahoma' color='black'>Content Technology Services-EMEA</b></font></p>");


Regards,
Punithkumar
0
Punithkumar
12/19/2007 12:14:46 PM

This is not working sir. 

hw.WriteLine("<p style=background-color:Red; align=left><b><font size='2' face='verdana' color='black'>SLA vs Actuals - Content Technology Services</font></b></p>");


Regards,
Punithkumar
0
Punithkumar
12/19/2007 12:16:06 PM

 Hi,

try this

hw.WriteLine("<p style=\"background-color:Red;\" align=left><b><font size='2' face='verdana' color='black'>SLA vs Actuals - Content Technology Services</font></b></p>");

look at the order of elements closing tags... 


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 12:17:32 PM

The text is displaying but the background color is not coming..


Regards,
Punithkumar
0
Punithkumar
12/19/2007 12:44:24 PM

 Hi,

its working fine... can you post your code? 


Vasanthakumar
Software Engineer.
0
vasanth
12/19/2007 12:56:27 PM

Is there any other tag in HTML to do this without using <p> and <table> tags..???


Regards,
Punithkumar
0
Punithkumar
12/19/2007 1:02:08 PM

 

I have written the following code in Button1_Click() event.. 

System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);

hw.WriteLine("<p style=\"background-color:Red;\" align=left><b><font size='2' face='verdana' color='black'>SLA vs Actuals - Content Technology Services</font></b></p>");
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=RequestPhoneID.xls");
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.End();


Regards,
Punithkumar
0
Punithkumar
12/19/2007 1:11:37 PM

Actually im exporting it to excel..There i wnt the color to be changed..


Regards,
Punithkumar
0
Punithkumar
12/19/2007 1:18:03 PM

Hi,

post your code.... 


Vasanthakumar
Software Engineer.
0
vasanth
12/20/2007 3:56:52 AM

System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);

hw.WriteLine("<p style=\"background-color:Red;\" align=left><b><font size='2' face='verdana' color='black'>SLA vs Actuals - Content Technology Services</font></b></p>");
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=RequestPhoneID.xls");
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.End();


Regards,
Punithkumar
0
Punithkumar
12/20/2007 5:39:14 AM

Hi, 

Punithkumar:
hw.WriteLine("<p style=\"background-color:Red;\" align=left><b><font size='2' face='verdana' color='black'>SLA vs Actuals - Content Technology Services</font></b></p>");
 

replace the above line as

 hw.WriteLine("<p style='background-color:Red;' align=left><b><font size='2' face='verdana' color='black'>SLA vs Actuals - Content Technology Services</font></b></p>");

I have tried what you are trying to do...

but its not working....

try to import directly from Datagrid or gridview.... 


Vasanthakumar
Software Engineer.
0
vasanth
12/20/2007 6:05:37 AM

Ya i tried..But the background color is not working sir..

Is there any other tag in HTML which can perform this task..

If i Do this my work wil be over

:-(


Regards,
Punithkumar
0
Punithkumar
12/20/2007 6:54:58 AM

From yesterday im trying that but im not getting..


Regards,
Punithkumar
0
Punithkumar
12/20/2007 6:57:10 AM

Hi,

try with <span> or <div> tags.. 


Vasanthakumar
Software Engineer.
0
vasanth
12/20/2007 7:01:14 AM

hw.WriteLine("<div style=\"background: green\"><h5 >SEARCH LINKS</h5></div>");

hw.WriteLine("<p>This is a paragraph <span style=\"background-color:#0000FF;\">This is a paragraph</span> This is a paragraph</p>");

 I tried with these two..

But this is not working..

 


Regards,
Punithkumar
0
Punithkumar
12/20/2007 7:25:03 AM

if i use color:#0000FF then the font color is changing..

But if i use background-color:#0000FF background is not changing..


Regards,
Punithkumar
0
Punithkumar
12/20/2007 7:28:32 AM

 Hi,

what is your requirement? 


Vasanthakumar
Software Engineer.
0
vasanth
12/20/2007 8:46:58 AM

help me please..

Im trying to do design like below..After exporting to EXCEL sheet i want this design on EXCEL sheet..

Font color is changing.. but the background color is not changing..

SLA vs Actuals - Content Technology Services
 

hw.WriteLine("<div style=\"background: yellow\">SLA vs Actuals - Content Technology Services</div>");

hw.WriteLine("<p><span style=\"background-color:#0000FF;\">SLA vs Actuals - Content Technology Services</span> This is a paragraph</p>");

hw.WriteLine("<p align=center><b><font size='2' face='tahoma' bgcolor='black'>Content Technology Services-EMEA</b></font></p>");

 I tried with these three lines..

But these are not working..

 help me..


Regards,
Punithkumar
0
Punithkumar
12/20/2007 9:39:54 AM

what exactly u want to do ? U want ot change a cell color in Excle or in asp.net gridview control?

if u want to change cell color in excel sheet then u have to create a excel sheets cell's object then u can chenge color of it.

or u can also use macro code to do this

0
pinakin2in
12/20/2007 9:47:15 AM

i want the background color of the text to be changed in an EXCEL sheet..


Regards,
Punithkumar
0
Punithkumar
12/20/2007 9:52:11 AM

genrate macro code in excle . then u can use it in code behind.

0
pinakin2in
12/20/2007 9:58:13 AM

 

ok forgot all this try following code

 

'Instantiating an Workbook object
Dim workbook As Workbook = New Workbook()


'Adding a new worksheet to the Workbook object
workbook.Worksheets.Add()


'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(0)


'Setting the foreground color of the "A1" cell to yellow
worksheet.Cells("A1").Style.ForegroundColor=Color.Yellow


'Setting the background pattern of the "A1" cell to vertical stripe
worksheet.Cells("A1").Style.Pattern=BackgroundType.VerticalStripe


'Setting the foreground color of the "A2" cell to blue
worksheet.Cells("A2").Style.ForegroundColor=Color.Blue


'Setting the background color of the "A2" cell to yellow
worksheet.Cells("A2").Style.BackgroundColor=Color.Yellow


'Setting the background pattern of the "A2" cell to vertical stripe
worksheet.Cells("A2").Style.Pattern=BackgroundType.VerticalStripe


'Saving the Excel file
workbook.Save(saveFileDialog1.FileName,FileFormatType.Default)


[JAVA]
//Instantiating an Workbook object
Workbook workbook = new Workbook();


//Accessing the added worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().addSheet();
Cells cells = worksheet.getCells();


//Accessing the "A1" cell from the worksheet     
Cell cell=cells.getCell("A1");
Style style = cell.getStyle();


//Setting the foreground color to yellow
style.setColor(Color.YELLOW);


//Setting the background pattern to vertical stripe
style.setPatternStyle(PatternType.VERTICAL_STRIPE);
//Saving the modified style to the "A1" cell.
cell.setStyle(style);


//Accessing the "A2" cell from the worksheet     
cell=cells.getCell("A2");
style = cell.getStyle();


//Setting the foreground color to blue
style.setColor(Color.BLUE);
//Setting the background color to yellow
style.setPatternColor(Color.YELLOW);
//Setting the background pattern to vertical stripe
style.setPatternStyle(PatternType.VERTICAL_STRIPE);
//Saving the modified style to the "A2" cell.
cell.setStyle(style);


//Saving the Excel file
workbook.save("C:\\output.xls",FileFormatType.DEFAULT);

0
pinakin2in
12/20/2007 10:03:43 AM

how to generate macro code in EXCEL

 

 


Regards,
Punithkumar
0
Punithkumar
12/20/2007 10:04:12 AM

 

if u r using c# then try

 //Instantiating an Workbook object
Workbook workbook = new Workbook();


//Adding a new worksheet to the Workbook object
workbook.Worksheets.Add();


//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];


//Setting the foreground color of the "A1" cell to yellow
worksheet.Cells["A1"].Style.ForegroundColor = Color.Yellow;


//Setting the background pattern of the "A1" cell to vertical stripe
worksheet.Cells["A1"].Style.Pattern = BackgroundType.VerticalStripe;


//Setting the foreground color of the "A2" cell to blue
worksheet.Cells["A2"].Style.ForegroundColor=Color.Blue;


//Setting the background color of the "A2" cell to yellow
worksheet.Cells["A2"].Style.BackgroundColor=Color.Yellow;


//Setting the background pattern of the "A2" cell to vertical stripe
worksheet.Cells["A2"].Style.Pattern=BackgroundType.VerticalStripe;


//Saving the Excel file
workbook.Save(saveFileDialog1.FileName,FileFormatType.Default);

0
pinakin2in
12/20/2007 10:05:02 AM

thank u. 

ya ok..ill try this and ill reply..


Regards,
Punithkumar
0
Punithkumar
12/20/2007 10:09:45 AM

ok sure

0
pinakin2in
12/20/2007 10:16:58 AM

Im missing an assembly reference for

c:\inetpub\wwwroot\test\WebForm8.aspx.cs(79): The type or namespace name 'FileFormatType' could not be found (are you missing a using directive or an assembly reference?)
c:\inetpub\wwwroot\test\WebForm8.aspx.cs(79): The type or namespace name 'saveFileDialog1' could not be found (are you missing a using directive or an assembly reference?)
c:\inetpub\wwwroot\test\WebForm8.aspx.cs(51): The type or namespace name 'workbook' could not be found (are you missing a using directive or an assembly reference?)


Regards,
Punithkumar
0
Punithkumar
12/20/2007 12:35:53 PM

u need to do is add a reference to the Microsoft Excel Interop Library which can be found in the COM components tab.

Add Excel Reference 

 

write foloowing two lines at  begining of vb file

Imports Microsoft.Office.Interop
Imports System.IO

Still if u face any error then u can visit  http://forums.asp.net/AddPost.aspx?ReplyToPostID=2070294&Quote=False

0
pinakin2in
12/21/2007 3:06:55 AM

I have one question please..

I am using a datagrid.

After clicking the edit button i want the width of the textboxes to be changed.

How this can be done..??

Help please..


Regards,
Punithkumar
0
Punithkumar
12/24/2007 11:47:36 AM

just go to the design of ur aspx page

right click on grid then select edit templete

apply appropriate size of text box.

 

 

if my answer helps u then plz mark it as answer so it can be usefull to others.

0
pinakin2in
12/25/2007 3:03:18 AM

thank u..

How to send attachment in HTML  MailTo tag


Regards,
Punithkumar
0
Punithkumar
12/28/2007 11:55:43 AM

This article explains how

http://aspnet.4guysfromrolla.com/articles/080206-1.aspx

Note:- Please open a new thread in future since this a totally question. That will benefit others who are searching for similar informaton


Jeev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you get the answer to your question, please mark it as the answer.
0
Jeev
12/28/2007 12:12:21 PM

Sub Send_Email (Src As Object, Args As EventArgs)

  If MailFrom.Text <> ""  AND MailTo.Text <> ""  AND Subject.Text <> ""  AND Body.Text <> "" Then

    Dim MailClient = New SmtpClient("localhost")
    Dim Email = New MailMessage
    Dim FileArray() As String
    Dim FileItem As String
   
    Try
   
    Email.From = New MailAddress(MailFrom.Text)
    Email.To.Add(New MailAddress(MailTo.Text))
    Email.Subject = Subject.Text
    Email.Body = Body.Text
    Email.IsBodyHtml = True
   
    If Attachments.Text <> "" Then
          FileArray = Directory.GetFiles(Server.MapPath("../Attachments/"))
          For Each FileItem in FileArray
                     Email.Attachments.Add(New Attachment(FileItem))
          Next
    End If

   
    MailClient.Send(Email)
    MailMsg.Text = "Email sent"
   
    Catch
               MailMsg.Text = "Error in sending email!"
    End Try
   
    If Attachments.Text <> "" Then
          Email.Attachments.Dispose()
           FileArray = Directory.GetFiles(Server.MapPath("../Attachments/"))
          For Each FileItem in FileArray
                   File.Delete(FileItem)
          Next
    End If

   
    MailFrom.Text = ""
    MailTo.Text = ""
    Subject.Text = ""
    Body.Text = ""
    Attachments.Text = ""
   
  End If

End Sub

0
pinakin2in
12/29/2007 8:10:17 AM

Thank u..

I have one doubt..

I am using Mailto tag in this way,(im using mailto tag in .aspx page)

 <A href="mailto:yyy@xxx.com?subject=Service;body=Open: .%0A%0a advisory:<%= txtPlannedMaintenance.Text %>&amp;">SendMail</A>

Im not able to make the body part bold..

How can i do this..

help me please.. 

 

 

 

 


Regards,
Punithkumar
0
Punithkumar
12/31/2007 11:14:53 AM

do like this :

mailMessage.IsBodyHtml = True 

mailMessage.Body = "A new Complaint(ID= " + strComplaintId + " ) is submitted to your Office. You can see the Complaint here <a href=http://www.msn.com>New Complaint</a>";

0
pinakin2in
1/1/2008 3:13:56 AM

Punithkumar:

I am using Mailto tag in this way,(im using mailto tag in .aspx page)

 <A href="mailto:yyy@xxx.com?subject=Service;body=Open: .%0A%0a advisory:<%= txtPlannedMaintenance.Text %>&amp;">SendMail</A>

Im not able to make the body part bold..

You cannot format the body when you are using mailto protocol. You can send emails in ASP.NET using classes in http://www.systemnetmail.com/

Thanks

-Mark post(s) as "Answer" that helped you


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
1/3/2008 9:49:23 AM

Thank u very much,

That link helped me a lot..


Regards,
Punithkumar
0
Punithkumar
1/3/2008 2:59:40 PM
Reply:

Similar Artilces:

Accessing cell text and changing background color (vb.net)
 Hello! I am trying to add on to the function below a feature that would change the background color of a row based on the cell values. I basically have 3 cells with data in them ('In Stock, Needed, On Order). If something is not in stock, I want the row to be red, if it's on order I need it to be yellow, and so on. What I am having trouble with is actually accessing the text values of the cells. I thought it was e.Row.Cells[2].Text but this hasn't worked. I am very new to vb.net as I usually use C# for this. It seems like any input I give it crashes. Adding a s...

Change cell color in a cell when hyperlink is clicked
I have a table across the bottom of my form, when a user clicks a hyperlink in one of the cells, I want the bgcolor of the cell to change. You can use the onClick event of the cell to change its bgcolor property. For example:<td bgcolor="black" onclick"bgcolor='white';">This is a test!</td>This uses event propogation to capture the click event which is passed down from the link. Steven BeyRecursion: see Recursion Don't know what I'm doing wrong, I used your example and it it doesn't want to cooperate. The bgcolor automatically deafults to the oncli...

Change Datagrid cell color based on cell value
I was wondering if there is a way to change the background color of an individual cell in a datagrid based on it's value. (I code in VB) Example: I have a Due Date field and the cells need to be highlighted yellow for all dates that are over 30 days old. Then for all of the dates that are over 60 days old, their cell backgrounds would need to be red. Thanks for the help in advance Dan Take a look @ Change Color of a Column Based on Column Values In your case you can use <Table> tag and change the <td> background color using helper function HTH Sushila Bowalekar PatelVisual ASP/ASP.NET MVPhttp://weblogs.asp.net/sushilasb It looks like it will work, I just have to customize it and make it fit what I need. Thanks for your help!! D I don't really like that solution. What I did was use the ItemDataBound method of the datagrid. This is called every time it writes out a row of the datagrid. Here's my code: Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then Select Case CType(e.Item.Cells(5).Text, Integer) Case Is >= 28 e.Item.BackColor = Drawing.Color.Red Case Is >= 21 e.Item.BackColor = Drawing.Color.Orange ...

Changing a Cells color based on another cells value
We want to change the color of a previous cell based on the value in the current cell. For example, say we are ranking items as they are read into the datagrid. We have several columns of data we want to rank for first and second place. Once we encounter a value that is greater than the previous high value we would like to change the previous high values cell color to yellow and the new high cells color to green. For example column 1 in the following table would have 12 highlighted in green and 10 highlighted in yellow. See the following table. Column 2 would have 11 highlighted green and th...

change grid cells back color (Cells Blinks)
Dear devs my case is im building a website similar to stocks websites, i used ajax for refreshing issues and gridview for disiplaying data. now the data will change frequently and i want to color the changed data (coloring the cells of changed data). but the problem is i dont know which cell is changed and which one staied remain. thanks for helpingJaffar N. Khalid Hi:   From your description my understanding is that you're using UpdatePanel and a Timer. Is it right? If my understanding is correct you can get the original data before GridView is bound again. Store it in a globa...

Changing cell colors in a datagrid based on the information contained in the cell
Any help I can get would be greatly appreciated. I have a datagrid with information in several columns that show the status of certain aspects of a given project. Red for an area in trouble in trouble, yellow for those having problems that could become serious and green for those running as planned. What I would like to do is have the cell color change to correspond to the status of the project. Since the project managers update the status of projects as needed the color would need to change based on the text entered into the cell turning either red, yellow or green to correspond. H...

Change color of a cell
How would I change the color of a cell from code. I can alter a table: ContentTable.BackColor = Color.Blue ,but I cannot figure out how to alter a cell. Any help would be welcome. Hi, I provided some sample code here: view post 834064. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons....

Net:Net:Net::LDAP::FAQ
------_=_NextPart_001_01C6429F.D89AA417 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Net::LDAP Net::LDAPS Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, ....) password? I don't like to write the secret password to the perl file. Best regards Barbara Wilbert ------_=_NextPart_001_01C6429F.D89AA417-- Wilbert Barbara (CI/OSI) * wrote: > Hello, > > Net::LDAP > Net::LDAPS > > Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, > ......

Changing cell color
I saw a previous question about how to set the color of an individual cell in a TStringGrid, and the solution was to use the GridDrawCell event to do it manually. However I need some help figuring out how to do that exactly... I have tried: Form2->Grid->Canvas->Brush->Color = clRed; Form2->Grid->Canvas->TextOutA(Rect.left, Rect.top, "Test"); This results in black text with a red background, however I just want the foreground to stay the same and change the text color only. I have also tried: Form2->Grid->Canvas->Pen->Color = clRed; ....

how do I conditionally change bkg color of datalist cell and make the content of the cell clickable
Hi all, 1) how do I change background color of a datalist cell based on an attribute value (of a xml file) and make the content of the cell clickable ? 2) assuming the datalist is in an iframe. How do I make the cell content value available to another iframe page via clickable/url passing technique?  Thanks Here's how to change the color (BALANCE_COL is the cell index): protected void GridViewFun_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.DataIt...

changing color of a cell
hi i have a hypelink within a tablecell. when i click the hyperlink i'd like to change te cell's backcolor. how can do it? i tried ..... <asp:tablecell id=cell1> <asp:hyperlink onclick="cell1.backcolor=green" navigateurl=page.aspx> ..... it doesnt work. can u tell me? thanks a lot   document.getElementById("someId").style..... but not sure you are adding it to that control the correct way.... EricPascarello.com | Twitter epascarello | LinkedIn hi   thanks <script language="javscript"> function ChangeCellColor(CellElement) {  CellElement...

Changing data grid cell colors based on information contained within the cells #2
I posted the following question the other day and aspdotnetv2 kindly responded with some code. However this seemed to require the use of the repeater control to accomplish my goal. It worked as it should. But if I do this I loose the functionally of the "data grid" that I wanted. Does anyone know a way to accomplish this using the data grid instead of the repeater?? I have a data grid with information in several columns that show the status of certain aspects of a given project. Red for an area in trouble in trouble, yellow for those having problems that could become serious ...

Change the color of datagrid cell..
Hi Friends, I want to change datagrid cell's back color by a single click on the cell. when i click in cell color will be changed and the next click on same cell i want to get the color which was before the single click. pls help me.. thanx in advance.   See folowing article http://www.codeproject.com/aspnet/AlPaMOD.asp?df=100&forumid=51730&exp=0&select=879011.You can do similar thing on mouse click event.Arvind Malik I wrote this rather quick. The example uses a table, but a datagrid is a table.....<html>  <head>    <script type="...

Change cell color in datagrid
Hello ppl... Do you know how can i chage color of specific cells (or items in some specific cells) in my datagrid? While putting data in dtrow i cannot put <font color='red'> tag in some columns because they contain integers and decimals Thanks in advance Bracoute Yuo can use the itemDataBound event : Sub DataGrid1_ItemBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) If e.Item.ItemType = ListItemType.Item Or _ e.Item.ItemType = ListItemType.AlternatingItem Then ' Change the color of cell 1 with CSS ...

change gridview cell color
I have a gridview with 3 columns, one of which has textboxes to display dates.I have a calendar control (custom).When i click the calendar icon, and choose a date, it displays it in teh textbox. Now, when i select a date, i want it to be displayed in red color or alteast i want to be able to changes the color of the textbox when i choose a date. I started with adding a onchange attribute to the textbox in the gridview rowdatabound event.But it does not seem to work.Any ideas? Here id my code for your reference.function colorChange() { document.getElementById("txtCurrentDate").style.backgroundColor = 'red'; }protected void gvEventSchedule_RowDataBound(object sender, GridViewRowEventArgs e) {  if (e.Row.RowType == DataControlRowType.DataRow) { //string script = "document.getElementById('" + "txtCurrentDate + "').value" ;TextBox dateBox = (TextBox)e.Row.FindControl("txtCurrentDate"); dateBox.Attributes.Add("OnChange", "colorChange()"); } }    Do you want to change the color for entire row? If so try this out:if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[2].BackColor = System.Drawing.Color.Red; }  Thanks,Karan~ Remember To Mark The Post(s) That Helped You As The ANSWER ~  Try it this wayFirst set the TextBox Autopostback = true2nd besure that your JS function doesn't have error 3rd add the word return like below if...

Changing color of a cell in a gridview
hello, If i have a gridview and i have following columns in it : FirstName, LastNname, Due Amount,  due date. 1)I want to check and change the color to red of that Cell in the Due Amount Column if the due Amount is more then 20 dollars, 2) change the color of a a Column Cell , DueDate  date if it is past due 30 days.   Thanks Amir        learning.. : ) You could put some logic in in the databinding logic:  Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowE...

Change the color of the cell in reports
Hi, I am developing reports in visual studio 2005 business intelligence studio. I am displaying a report and i want to change color of the particular cell. if cell.value>90 then cell_color="Red" else cell_color="Green" end if Thanks.   Regards Arshad  Please Mark as Answer if the post is helpful to you.  set this to "color" cell property:=iif(Fields!MY_VALUE.Value>90,"Red","Green")  Regards,Stefan Uzunov ThanksPlease Mark as Answer if the post is helpful to you....

Changing back color of cell
Hi, I have a tree which generate data from a rdf-template. Now I want to change the color only of the cell which contains negative ( - ) value. How can it possible? Regards, Sandesh Sandesh Karalkar wrote: >I have a tree which generate data from a rdf-template. >Now I want to change the color only of the cell which contains negative ( - ) value. > >How can it possible? > Basically you need the RDF data source to tell the tree what colour you want the cell to be. First, your template needs to specify the properties attribute as well as the value...

datalist cell color change
i have a form which presents a list of access database records bound to a datalist. I have a column which displays all the due_dates. What i would like to do is change the colour of the entire row whenever there is a due_date record which is less than the current date. I am using vb.net behind my aspx page. Any ideas as to a basic function i would use here?   Thankyou Translated from C#:  Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As DataListItemEventArgs) Dim DVR As DataRowView = TryCast(e.Item.DataItem, DataRowView) If DVR IsNot Nothing...

change the cell color by radiobutton
i have a table 3 columns wide.. each row holds a label..radiobutton..radiobutton when the user clicks on a radiobutton.. the cell turns blue or a color.. when the user clicks the other radiobutton.. that cell turns blue or a color.. i know it is a javascript.. but how??  ideas??...

How to change the color of DataGrid cell ?
Can I change the color of DataGrid cell based on the value from a database? You may use "DataGrid1.Items[X].Cells[X].BackColor".This posting is provided "AS IS" with no warranties, and confers no rights. Thanks, Can you give me one example please? I used it as following but it gave me an error : MyDataGrid.Items[1].Cells[1].BackColor="blue" Regards. You may try this: MyDataGrid.Items[1].Cells[1].BackColor=Color.Blue This posting is provided "AS IS" with no warranties, and confers no rights....

How to change the color of the cells of the Gridview
Hi, I have a link button.when i click on that button,I want to open a new page that contains a gridview having two columns.Based upon User logins,i want to reset the color of the gridview,any idea?  hi sangeeta,in row databound of your gridview do this If User.Identity.Name = "ADMIN" Then            If e.Row.RowType = DataControlRowType.Header Then                e.Row.BackColor = System.Drawing.Color.SkyBlue     &nbs...

Changing cell background color
    Hello, Im trying to make a navigation menu thing kind of like the one at the top of the asp.net page. Where the background color of the cell changes to a different color when your mouse goes over it and changes to another color when its clicked.Does any one know of any good tutorials etc on how to do this? (im quite new btw :P)Thanks!Sorry if that doesnt make sence and have posted in the wrong area :(( Hi Anthony,   If you're looking for same navigation bar as like as ASP.NET, check it out from CommunityServer Source. it is basically opensource - so you can use/sha...

Changing the value of one cell when the user changes the value of another cell
I am using a standard GridView with multiple columns and a SQLDataSource. One column is called Qty and another column is called Date. When the user clicks the Edit button and enters a quantity into the Qty column, I would like to automatically fill in today's date into the Date column...before the user clicks Save. Any ideas on how to do that? Thanks in advance, Rick     You would have to make an asych call, check out ASP.NET AJAX: http://ajax.asp.net add a javascript event on the quantity textbox the onchange On the gridviews rowdatabound add this  Protected Sub Gr...

Web resources about - Change Color of a cell - asp.net.faq

Name change - Wikipedia, the free encyclopedia
For name changes within the Wikipedia community, see Wikipedia:Changing username . For name changes of places rather than persons, see Geographical ...

Record-breaking heat shows world 'losing battle' against climate change, Alan Finkel tells Q&A
Australia's chief scientist warns the planet is losing the battle against climate change, after new data shows February set a unprecedented record. ...

Parents of TV Reporter Killed On Air Continue to Push For Change
Six months ago, WDBJ reporter Alison Parker and cameraman Adam Ward were killed after a gunman–their former co-worker –shot them in cold blood, ...

Former CIA director calls out the FBI for wanting to fundamentally change the iPhone
The FBI's demand that Apple create a custom version of iOS that would allow them to hack into the iPhone of one of the San Bernardino terrorists ...

Mainstream News Coverage Of Climate Change Fell Dramatically In 2015, Hottest Year On Record By Far
... published on Sustainnovate. By Henry Lindon A new report from Media Matters has revealed that US broadcast news coverage of climate change fell ...

Board OKs name change for school with segregationist's name
RICHMOND, Va. (AP) — A Virginia school division has decided to remove a prominent segregationist's name from a school building.

Yes, climate change is making some #ExtremeWeather worse
Scientists can link climate change to the growing severity and duration of some extreme weather events, according to a new report by the highly ...

Open thread for night owls: Yglesias says Sanders convinced him to change his mind on free college
At Vox, Matthew Yglesias writes— How Bernie Sanders convinced me about free college : In its early months, Bernie Sanders's presidential campaign ...

Lupita Nyong'o Opens Up About Going Bald, the Oscars Curse and Industry Discrimination: 'Change Has to ...
Lupita Nyong'o Opens Up About Going Bald, the Oscars Curse and Industry Discrimination: 'Change Has to Happen'

Google CIO Ben Fried Says Make Change A Core Competency
I interviewed Ben Fried, CIO of Google, on stage at the Forbes CIO Summit earlier this week, and he offered a number of keen pieces of advice ...

Resources last updated: 3/15/2016 1:27:33 PM