开发者

GridView Row Focus

开发者 https://www.devze.com 2023-03-15 08:25 出处:网络
I have a gridview with paging allowed.out side the gridview i have textBox and a button.when i type something and press the button i need the gridView row which contains that value to change its backg

I have a gridview with paging allowed.out side the gridview i have textBox and a button.when i type something and press the button i need the gridView row which contains that value to change its background colour an开发者_StackOverflow社区d the if the row is in a different page other than the current page.i need that page to be visible.following code doesn't work for me.

protected void Button1_Click(object sender, EventArgs e)
        {
            int PIndex = -1;

            foreach (GridViewRow Rowitem in GridView1.Rows)
            {
                Rowitem.BackColor = Color.White;

            }

            for (int x = 0; x < GridView1.PageCount; x++)
            {


                foreach (GridViewRow Rowitem in GridView1.Rows)
                {
                    for (int i = 0; i < Rowitem.Cells.Count; i++)
                    {
                        if (Rowitem.Cells[i].Text  == TextBox1.Text)
                        {

                            PIndex = x;
                            GridView1.PageIndex = PIndex;
                            Rowitem.BackColor = Color.BlueViolet;
                        }
                    }

                }
            }


           LoadGrid();
           GridView1.DataBind();
        }


why you are not use row bound event of grid view,i think i will its to check value

0

精彩评论

暂无评论...
验证码 换一张
取 消