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个字符串的用.....表示,求解~
解决方案 »
- 紧急求助!!!
- 继承自Button的自定义控件,从工具箱插入时为什么VS2010不能生成相应的源代码?
- PrecompiledApp.config 与 Global.asax
- 上传是以B为最小单位计算的吗? .NET
- validateRequest="false " enableEventValidation="false"对页面有什么影响吗?
- 非哥请进
- 像CSDN树形菜单是怎么做得,点击一个节点时显示"正在加载数据.."
- 装Visual Studio .NET 2003后不能新建项目,请教???????
- 问个小小的关于添加记录的代码问题
- 谁能解释Application_Start Session_Start Session_End Application_End
- 无法保存;正被别的用户锁定。 ?
- 左侧折叠菜单 一个打开时另一个收起
然后
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)+"……";
}
}
}
{ 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的
{
DataTable dt = NewBusiness.GetTop8News();
GridViewNew.DataSource=dt;//GridViewNew是GridView的ID
GridViewNew.DataBind();
}
4楼直接从sql弄也可以 。