Home > DeveloperSection > Forums > linkbutton to expand gridview causes row colors from function to be lost
Tanuj Kumar

Total Post:134

Points:940
Posted on    August-23-2014 7:29 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 607  View(s)
Rate this:

When a Link button I have in my gridview that expands the table to show a nested gridview i lose all the row colors that i get from this function. What I need is a way to call the function when the link 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>



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    August-23-2014 8:54 AM

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" });

            }

            })

        });


Don't want to miss updates? Please click the below button!

Follow MindStick