LINKBUTTON TO EXPAND GRIDVIEW CAUSES ROW COLORS FROM FUNCTION TO BE LOST

Total Post:134

Points:940
 953  View(s)
Ratings:
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>
  1. Post:378

    Points:2694
    Re: linkbutton to expand gridview causes row colors from function to be lost

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

      Modified On Apr-04-2018 06:52:00 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!