DataGride中有三列分别的:种类,题目,时间我的要求是将
种类值为1的用图片显示,图片地址是<img src='/images/image1.gif'>
种类值为2的用图片显示,图片地址是<img src='/images/image2.gif'>
别的列就文一般文字显示这样的话怎么写SELECT语句和怎么样绑定到DataGride我是这样写的:(错的)comstr="SELECT (case type when 1 then <img src='/GBook_start/images/image1.gif'> else
<img src='/GBook_start/images/image2.gif'> end ) as type,
title,datetime FROM GB_LeaveWord "
下面进行绑定SqlDataAdapter da=new SqlDataAdapter(comstr,myConnection);
DataSet ds=new DataSet();
try
{
myConnection.Open();
da.Fill(ds,startIndex,DataGrid1.PageSize,"mytable");
da.Fill(ds,"alltable");
DataGrid1.VirtualItemCount=ds.Tables["alltable"].Rows.Count;
DataGrid1.DataSource=ds.Tables["mytable"].DefaultView;
DataGrid1.DataBind();
}
种类值为1的用图片显示,图片地址是<img src='/images/image1.gif'>
种类值为2的用图片显示,图片地址是<img src='/images/image2.gif'>
别的列就文一般文字显示这样的话怎么写SELECT语句和怎么样绑定到DataGride我是这样写的:(错的)comstr="SELECT (case type when 1 then <img src='/GBook_start/images/image1.gif'> else
<img src='/GBook_start/images/image2.gif'> end ) as type,
title,datetime FROM GB_LeaveWord "
下面进行绑定SqlDataAdapter da=new SqlDataAdapter(comstr,myConnection);
DataSet ds=new DataSet();
try
{
myConnection.Open();
da.Fill(ds,startIndex,DataGrid1.PageSize,"mytable");
da.Fill(ds,"alltable");
DataGrid1.VirtualItemCount=ds.Tables["alltable"].Rows.Count;
DataGrid1.DataSource=ds.Tables["mytable"].DefaultView;
DataGrid1.DataBind();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货