Hi Folks,
I have created one gridview.In that gridview i've placed buttons in every cells.My task here is...when i click the button automatically that particular cell color should get changed.I even used code using system.drawing.color on selected index changing event.But once i click any one cell it affects all the cell.For your reference iam sending you my sample code can you please help me out with this.

On SelectedIndexChanging()
{
GridView1.Rows[0].Cells[0].BackColor = System.Drawing.Color.WhiteSmoke;
        GridView1.Rows[0].Cells[1].BackColor = System.Drawing.Color.Beige;
        GridView1.Rows[0].Cells[2].BackColor = System.Drawing.Color.Tomato;
        GridView1.Rows[1].Cells[0].BackColor = System.Drawing.Color.CadetBlue;
        GridView1.Rows[1].Cells[1].BackColor = System.Drawing.Color.DarkOliveGreen;
        GridView1.Rows[1].Cells[2].BackColor = System.Drawing.Color.DarkSlateGray;
        GridView1.Rows[2].Cells[0].BackColor = System.Drawing.Color.ForestGreen;
        GridView1.Rows[2].Cells[1].BackColor = System.Drawing.Color.CornflowerBlue;
        GridView1.Rows[2].Cells[2].BackColor = System.Drawing.Color.Cornsilk;
}

Kindly check the code and help me out with this task.


Thanks and Regards,
Leo franklin.M

Recommended Answers

All 2 Replies

Good Afternoon lefrancisco1

You are using the Wrong event

use

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

Hope it Helps


Vuyiswa Maseko

Read about Event-Bubbling. It's prime concept to handle events for child controls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.