在datagrid中规定固定长度,但显示的数据的长度要超过控件规定的长度,而显示的时候,是要自动换行,直到显示完,如何能让控件自动控制,长超过这个长度的内容消掉,而不换行,直接显示可看到的。
使得显示的多条,可以只显示因为长度内的。

解决方案 »

  1.   

    <asp:BoundColumn DataField="LostDescription" HeaderText="物品特征">
    <ItemStyle Height="20px"  CssClass="infoDatagrid"></ItemStyle>
    .css
    .infoDatagrid
    {
    height:20px;
     Width:400px;
     overflow:hidden;
    }
      

  2.   

    string str=""//你要显示的内容.
    this.TextBox2.Text = str.Substring(0,6)//在TextBox2中显示此字符串的前6位.
    你在数据邦定的位置改一个就OK了,this.TextBox2.Text = str.Substring(0,6)+...
      

  3.   

    我用的是这样的,<td width="300"><%# container.dataitem("文章题目")%></td>
    用了上边的方法,不行呀
      

  4.   

    <td width="300"><%# container.dataitem("文章题目").ToString().Substring(0,6)%></td>
      

  5.   

    <%# container.dataitem("文章题目").ToString().Substring(0,20)+"..."%>这样只显示20个字符,剩下的就直接显示...也可以加个超级连接到其他页面帮助用户查看全部信息<a href=..... target=_blank> <%# container.dataitem("文章题目").ToString().Substring(0,20)+"..."%> </a>
      

  6.   

    呵呵你直接在sql语句中用substring去截取就行了,何必还得麻烦控件大哥了?
      

  7.   

    你直接在sql语句中用substring来截取(注意substring指的是相应数据库的截取字符串函数)
      

  8.   

    <asp:TemplateColumn HeaderText="ReadMe">
      <ItemTemplate>
                           <asp:Label ID="lblReadMe" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ReadMe") %>' />
                      </ItemTemplate>
      <EditItemTemplate>
                         <asp:TextBox runat="server" id="txtReadMe" Text='<%# UFormat(DataBinder.Eval(Container.DataItem, "ReadMe")) %>' TextMode="MultiLine" Rows="3"/>
                         <asp:RequiredFieldValidator id="reqval_ReadMe" Text="Can't Null" ControlToValidate="txtReadMe" Display="Dynamic" Font-Name="arial" Font-Size="12" runat=server/>
      </EditItemTemplate>
     </asp:TemplateColumn>
      

  9.   

    ItemDataBound里
    .....
    if (e.Item.ItemType == ListItemType.EditItem)
    {
    TextBox txt = (TextBox)e.Item.Cells[0].Controls[0];
    txt.Width = Unit.Pixel(100);
    txt.MaxLength=9;
    txt.Text=txt.Text.Trim();
    ......
    }
    ....
    你都看看吧!
      

  10.   

    select left(title,50) as title from article
    select substring(title,1,50) as title from article