---
title: "linkbutton to expand gridview causes row colors from function to be lost"  
description: "linkbutton to expand gridview causes row colors from function to be lost"  
author: "Anonymous User"  
published: 2014-08-23  
updated: 2014-08-23  
canonical: https://www.mindstick.com/forum/2100/linkbutton-to-expand-gridview-causes-row-colors-from-function-to-be-lost  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# linkbutton to expand gridview causes row colors from function to be lost

When a [Link](https://www.mindstick.com/articles/23633/link-builder) button I have in my [gridview](https://www.mindstick.com/articles/873/update-delete-edit-gridview-in-asp-dot-net) that expands the [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) to show a [nested](https://www.mindstick.com/forum/45/itemcommand-event-in-nested-repeater-and-listview) gridview i lose all the [row](https://www.mindstick.com/forum/1212/this-row-already-belongs-to-this-table) [colors](https://answers.mindstick.com/qa/31019/should-i-paint-my-interior-with-neutral-or-bright-colors) that i get from this [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server). What I need is a way to call the function when the link [button is clicked](https://www.mindstick.com/forum/157821/write-a-jquery-code-that-selects-all-the-checkboxes-in-a-form-when-a-select-all-button-is-clicked).

```
 <script type="text/javascript">      $(document).ready(function () {            $("#<%=GridView1.UniqueID%> tr").each(function () {                var status = $(this).children('td:eq(6)').text();                if (status == 'OK') {                    $(this).children('td').css({ "background-color": "lightgreen" });                   }                else if (status == 'XL') {                $(this).children('td').css({ "background-color": "RED" });            }               else if (status == 'CL') {                $(this).children('td').css({ "background-color": "YELLOW" });            }            })        });</script>
```

## Replies

### Reply by Sumit Kesarwani

Hi Tanuj, \

I can see one problem with this code :

Your last function will override all others(i think) Why don't you try:

```
 $(document).ready(function
() {           
$("#<%=GridView1.UniqueID%> tr").each(function () {                var number = $(this).children('td:eq(6)').text();                if (number == 'OK') {                   
$(this).children('td').css({ "background-color":
"lightgreen" });                    }                else
if (number == 'XL') {               
$(this).children('td').css({ "background-color":
"RED" });            }               else if(number == 'CL') {               
$(this).children('td').css({ "background-color":
"YELLOW" });            }            })        });
```


---

Original Source: https://www.mindstick.com/forum/2100/linkbutton-to-expand-gridview-causes-row-colors-from-function-to-be-lost

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
