我是手动绑定数据源到gridview控件的,只有一个字段,因为这个字段中的内容很多,运行后gridview控件会被拉的很宽,反正多少内容也是一行显示。
我先在gridview的样式中限定宽度为500px,但运行后还是会被拉的很宽。再试着写语句如:GridView1.Width = Unit.Pixel(500);运行后还是会被拉宽.
请教大家,有什么办法限定它的宽度呢?

解决方案 »

  1.   

    弄个模板列.然后拖进去一个textbox ,就可以了1!
      

  2.   

    将它放在div中,设置div的宽度
    div不熟的话 
    就服务器panel
      

  3.   

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="OrderID" OnRowDataBound="GridView1_RowDataBound" >
    <Columns>
    <asp:TemplateField ShowHeader="False">
        <ItemTemplate>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>   protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        TextBox t1;
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            t1 = e.Row.FindControl("TextBox1") as TextBox;
            if (t1 != null)
            {
                t1.Width = 400;
            }
        }
    }
      

  4.   

    1/2/3楼的方法我都认真实验过了,表格会被撑宽,div也会被撑宽,panel还会被撑宽,太郁闷了,继续等答案