Home > DeveloperSection > Forums > How to use Linkbutton in Gridview using C#
Madam Walker
Madam Walker

Total Post:22

Points:154
Posted on    October-05-2013 7:44 AM

 C# C# 
Ratings:


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

I have a code like this

        GridViewRowCollection row1 = GridView2.Rows;
        foreach (GridViewRow row in GridView2.Rows)
        {
            LinkButton objlink = (LinkButton)row.FindControl("LinkButton2");
            objlink.ForeColor = Color.Blue;
        }
        LinkButton objrow1 = (LinkButton)(e.CommandSource);
        objrow1.BackColor = Color.BurlyWood;

When I click the one of the command source , like name.. it changes the bgcolor for that name ,but I also want to click one more time on same name to to disable bg color..

How can i achieve this?

Thanks in advanced!



Ida B Wells
Ida B Wells

Total Post:30

Points:210
Posted on    October-05-2013 8:59 AM

Maintain a hidden variable near to that button and set the value of that as "0" by default. Every time you click on the adjacent button, Increase the value of this hidden variable. Now in the click event you can check the current value and decide whether you want to change the background color to Blue or Re or whatever color you want


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

Follow MindStick