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

 

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;

                }

 

            }

        }

       

    }

posted on 2007-10-19 10:20  LongSky  阅读(317)  评论(0编辑  收藏  举报

导航