AspxGridView动态加载图片
请教: 图片文件存于文件夹中,我希望在AspxGridview中,根据单元格的值,显示不同的图片。(aspxgridview的数据,由程序产生,全部是0,-1,1数据,希望显示三种图片)
请问,我该怎么做?先谢了!
------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if(e.Row.Cells[1].Text==-1){e.Row.Cells[1].Text="<img src='../images/settings.png'/>";}
//这里可根据你的需求判断呗
}
}
------解决方案--------------------protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
switch (e.Row.Cells[1].Text)
{
case "0":
e.Row.Cells[1].Text = "<img src='../images/0.gif'/>"; break;
case "1":
e.Row.Cells[1].Text = "<img src='../images/1.gif'/>"; break;
case "-1":
e.Row.Cells[1].Text = "<img src='../images/2.gif'/>"; break;
}
}
}
------解决方案--------------------同意!
------解决方案--------------------前台Columns里加一列
<dx:GridViewDataColumn VisibleIndex="7">
<HeaderTemplate>
图片
</HeaderTemplate>
<DataItemTemplate>
<table>