日期:2014-05-18  浏览次数:20374 次

求教图片处理
各位大哥:
   
        我用Gridview动态绑定图片,然后给他做超链接,可是如果用HyperLink的话,可以做超链接,但是我控制不了图片大小,用ImageField可以控制图片大小,却不会给他做超链接,还有就是如果数据库中有这张图,让他显示,没有的话就不让他显示,怎么做.
谢谢.

------解决方案--------------------
自己做GridView的Template..拉个Table做个IMG进去不就可以了!!!
不要用GridView自带的!!

------解决方案--------------------
http://dotnet.aspx.cc/article/b7db5950-09f6-4119-841e-dc20426d0528/read.aspx

HyperLink 控件控制图片宽度高度的几种方法
------解决方案--------------------
a中嵌入img
<a>
<img />
</a>
------解决方案--------------------
// 模版列,类似如下
// 无论如何,你都注意相对路径的正确解析

<itemtemplate>
<a href= ' <%# Eval( "MyImageUrlField ") %> '> <img src= ' <%# Eval( "MyImageUrlField ") %> ' border=0 /> </a>
</itemtemplate>
------解决方案--------------------
关注..
Dim row As DataRowView
Dim img As Image
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then
row = DirectCast(e.Item.DataItem, DataRowView)
If row(“PictureUrl”).ToString().Trim() = “” Then
img = DirectCast(e.Item.FindControl(“NewsImage”), Image)
img.Visible = False
End If
End If
------解决方案--------------------
这个在样式里面设置就可以了!!
------解决方案--------------------
在DataGrid里可里加ItemCommand事件 (如下做法) GridView应该也可以 试试看
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
{
e.Item.Cells[0].Text= " <font color=#ff0000> "+e.Item.Cells[0].Text+ " </font> "; }
}
------解决方案--------------------
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button btnCheck = (Button)e.Row.FindControl( "btnCheck ");
Button btnDelete = (Button)e.Row.FindControl( "btnDelete ");


btnCheck.CommandArgument = e.Row.RowIndex.ToString();
btnDelete.CommandArgument = e.Row.RowIndex.ToString();

}

}
可能在GridView1控件的RowCreated事件中处理,在当控件生成数据的时候来做,不管是你用什么控件都可以实现你的要求.
楼主只要改一下上面的程序就可以.
------解决方案--------------------
使用GV的模板列