如何确定列的宽度 [英] How can determine the width of the column

查看:98
本文介绍了如何确定列的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以通过GridView向我提供有关确定列宽度的信息



谢谢....

解决方案

您可以尝试在 RowDataBound 事件上设置宽度

  protected   void  GridView1_RowDataBound( object  sender,GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells [ 0 ]。宽度= 单位( 600px的);
}
}


我已准备好使用

 GridView1.Columns [ 0 ]。ItemStyle.Width =  50 ; 



但它说错误:



{索引超出范围。必须是非负数且小于集合的大小。\\\\ nParameter name:index}


can any body provide me about determine the width of the column with GridView

thanks....

解决方案

You can try to set the width on RowDataBound event

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if( e.Row.RowType == DataControlRowType.Header )
    {
        e.Row.Cells[0].Width =new Unit("600px");
    }
}


i all ready use

GridView1.Columns[0].ItemStyle.Width = 50;


but it say error :

{"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"}


这篇关于如何确定列的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆