GridView在编辑的时候控制编辑框的列宽。

protected void gvWKPL_RowEditing(object sender, GridViewEditEventArgs e)

{

foreach (TableCell varcell in gv.Rows[gv.EditIndex].Cells)

{

try

{

TextBox curText = (TextBox)varcell.Controls[0];

curText.Width = Unit.Pixel(50);

//对于不知道名字的就要用这种写法

//对于模版列也可以用、、//((TextBox)gv.Rows[editIndex].FindControl("TextBox4"));

}

catch

{

continue;

}

}

 

//再不行了就在这里搞

protected void gvWKPL_DataBound(object sender, EventArgs e)

    {

        if (gvWKPL.EditIndex != -1)

        {

            foreach (TableCell varcell in gvWKPL.Rows[gvWKPL.EditIndex].Cells)

            {

                try

                {

                    TextBox curText = (TextBox)varcell.Controls[0];

                    curText.Width = Unit.Pixel(50);

                }

                catch

                {

                    continue;

                }

 

            }

        }

       

    }

相关文章:

  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-11-05
  • 2022-02-01
  • 2021-11-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
  • 2021-12-19
相关资源
相似解决方案