在gridview里面,如何显示有两种值的字段?比如:sk表里面paiming字段的值分别是0和1,当值是0的时候,button1显示,button2就显示为灰色;当值是1的时候,button2显示,button1就显示为灰色.在gridview里怎么做啊要?

解决方案 »

  1.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            int i = 0;
            Button button1 = (Button)e.Row.FindControl("button1");
            Button button2 = (Button)e.Row.FindControl("button2");
            string value = e.Row.Cells[0].ToString();
            if (button1 != null)
            {
                if (value == 0)
                {
                    button1.Enabled = true;
                    button2.Enabled = false;
                }
                else
                {
                    button1.Enabled = false;
                    button2.Enabled = true;
                }
            }
        }
      

  2.   

    Click the link to solve your problem.Good luck!