用datagrid显示10条新闻标题 想要如题效果 如何设置呢
datagird.ToolTip 如何设置呢还有一个问题 我现在进入详细浏览新闻页面后 只是读出数据库中的新闻主题字段 没有分段很多段都是连在一起的 只是作为字符串输出了 如何能分段呢 

解决方案 »

  1.   

    You may refer to http://www.webasp.net/article/26/25714.htm for the first question.As for the second question, you may replace blank with html tag <br>.
      

  2.   

    如果你是使用链接列绑定你的数据,你完全可以直接绑定此HyperLink,如下:
    <asp:HyperLink id="HyperLink1" runat="server" ToolTip='<%# DataBinder.Eval(Container, "DataItem.ToolTip") %>'><%# DataBinder.Eval(Container, "DataItem.title") %></asp:HyperLink>如果你并非使用模板列而是直接绑定,你可以在SQL中实现
    sql = "select '<a href=xxx.aspx?id=' & id & ' title=这是新闻>' & title & '</a>' as title from table ";
    如此,直接绑定即可.
      

  3.   

    hchxxzx(NET?摸到一点门槛) 厉害啊,还有这种方法,
      

  4.   

    hchxxzx(NET?摸到一点门槛) 厉害啊,还有这种方法,
      

  5.   

    可以使用一个模板列,然后使用<a title></a>来显示Tooltip
    <ItemTemplate>
    <A title='<%# DataBinder.Eval(Container,"DataItem.Titlex")%>' href='MNews/IndexNews.aspx?ID=<%# DataBinder.Eval(Container,"DataItem.ID")%>'>
         <%# DataBinder.Eval(Container,"DataItem.Title")%>
             </A>
    </ItemTemplate>以上的title 就是鼠标放上去之后显示如Tooltip的形式一样
      

  6.   

    把取出来的数据进行处理一下,然后再显示
    public string MyReplace(string mystr)
    {
    if(mystr == null || mystr == "" )
    {
    return("&nbsp;");
    }
    else
    {
    mystr = mystr.Replace("\n\r","<br>");
    mystr = mystr.Replace("\r","<br>");
    mystr = mystr.Replace("\t","  ");
    return(mystr);
    }
    }