public static DataTable GetTop8News()
        {
            string sql = "select top 8 * from T_News where newID=1  order by newsTime desc ";
            DataTable dt = DataHelp.ExcuteSqlReturnTable(sql);
            return dt;
        }SQLHelppublic static DataTable ExcuteSqlReturnTable(string sql)
        {
            try
            {
                SqlCommand command = new SqlCommand(sql, connection);
                SqlDataAdapter adpater = new SqlDataAdapter(command);
                DataTable dt = new DataTable();
                adpater.Fill(dt);
                return dt;
            }
            catch (Exception ex)
            {
                return null;
            }
        }多于10个字符串的用.....表示,求解~

解决方案 »

  1.   

    你应该把返回的datatable绑定到某个控件吧,比如repeater、gridview
    然后
     protected void gv_Test_RowDataBound(object sender, GridViewRowEventArgs e)
        {        if (e.Row.RowType==DataControlRowType.DataRow)
            {
                  if (e.Row.Cells[0].Text.length>100)
                {
                    e.Row.Cells[0].Text=e.Row.Cells[0].Text.Substring(1, 100)+"……";
                }
            }
        }
      

  2.   

     protected void gv_Test_RowDataBound(object sender, GridViewRowEventArgs e)
        {        if (e.Row.RowType==DataControlRowType.DataRow)
            {
                  if (e.Row.Cells[0].Text.length>10)
                {
                    e.Row.Cells[0].Text=e.Row.Cells[0].Text.Substring(1, 10)+"……";
                }
            }
        }
    这是gridview的
      

  3.   

    补充下这个是cs里面的,怎样将组合它们,我刚学,不太懂public void NewsDataGridViewBind()
        {
            DataTable dt = NewBusiness.GetTop8News();
            GridViewNew.DataSource=dt;//GridViewNew是GridView的ID
            GridViewNew.DataBind();
        }
      

  4.   

     string sql = "select top 8 * ,SUBSTRING(新闻标题字段,1,10) as 别名 from T_News where newID=1  order by newsTime desc ";在程序绑定就用 别名
      

  5.   

    你可以在绑定的时候 用个后台方法处理下 。
    4楼直接从sql弄也可以 。