GridView 绑定数据之后 数据自动换行  
现在是这样的:
                  123 123 123
                          123
                  456 456 456
                          456
怎么变成这样:
                  123 123 123123
                  456 456 456456

解决方案 »

  1.   

    <asp:GridView ID="GridView1" ShowFooter="true" BorderColor="Black" OnRowDataBound="GridView1_RowDataBound"   runat="server" AutoGenerateColumns="False"  Font-Size="12px" Width="530px" AllowSorting="True">
              <Columns>
                  <asp:TemplateField HeaderText="账号">
                      <ControlStyle Width="100px" />
                      <ItemTemplate>
                          <asp:Label ID="lbID" runat="server" Text='<%# Bind("EmpID") %>'></asp:Label>
                      </ItemTemplate>
                      <FooterTemplate>
                          <asp:TextBox ID="txtID" runat="server"></asp:TextBox>
                      </FooterTemplate>
                  </asp:TemplateField>
                  <asp:TemplateField HeaderText="姓名">
                      <ControlStyle Width="100px" />
                      <ItemTemplate>
                          <asp:Label ID="lbRealName" runat="server" Text='<%# Bind("EmpRealName") %>'></asp:Label>
                      </ItemTemplate>
                      <FooterTemplate>
                          <asp:TextBox ID="txtRealName" runat="server"></asp:TextBox>
                      </FooterTemplate>
                  </asp:TemplateField>
                  <asp:TemplateField HeaderText="性别">
                      <ItemTemplate>
                          <asp:Label ID="lbSex" runat="server" Text='<%# Bind("EmpSex") %>'></asp:Label>
                      </ItemTemplate>
                      <FooterTemplate>
                          <asp:DropDownList ID="ddlSex" runat="server">
                             <asp:ListItem Value="男">男</asp:ListItem>
                             <asp:ListItem Value="女">女</asp:ListItem>
                          </asp:DropDownList>
                      </FooterTemplate>
                  </asp:TemplateField>
                  <asp:TemplateField HeaderText="住址">
                      <ControlStyle Width="200px" />
                      <ItemTemplate>
                          <asp:Label ID="lbAddress" runat="server" Text='<%# Bind("EmpAddress") %>'></asp:Label>
                      </ItemTemplate>
                      <FooterTemplate>
                          <asp:TextBox ID="txtAddress" runat="server" Width="80px"></asp:TextBox>
                          <asp:Button ID="btnAdd" runat="server" Text="添 加" OnClick="btnAdd_Click" />
                          <asp:Button ID="btnCancel" runat="server" Text="取 消" OnClick="btnCancel_Click" />
                      </FooterTemplate>
                  </asp:TemplateField>
              </Columns>
              <HeaderStyle BackColor="Azure" Font-Size="12px" HorizontalAlign="Center" />
                <RowStyle HorizontalAlign="Center" />
                <PagerStyle HorizontalAlign="Center" />
            </asp:GridView>
      

  2.   

    label显示的结果吗?
    不是的话 截取字符串
    或  css设置过长...代替
      

  3.   

    用样式,GridView的html代码其实是一个表格,你能通过CSS控制table的样式即能控制gridview的样式
      

  4.   

    设置为不允许换行啊
    Wrap 设置成 false
      

  5.   

    itemstyle
    正常换行
     GridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");
     //自动换行
     GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");