问题:在gridview中建模板列嵌套Image控件用于显示图片.不论我怎么调,前台图片都显示不了,查源代码,发现src="";为空.我试了把图片路径用相对路径,绝对路径都试了,怎么调都不行.请教高手指点.后台代码
protected void GridView6_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer)
{
Image strimage = (Image)e.Row.Cells[2].FindControl("image3");
strimage.ImageUrl = "http://localhost/oa/image/new5.gif";
}
}
前台代码:
<asp:GridView ID="GridView6" runat="server" AutoGenerateColumns="False" ShowHeader="False" BorderWidth="0px" Width="100%" OnRowDataBound="GridView4_RowDataBound" BorderStyle="None" OnDataBound="GridView6_DataBound">
<RowStyle Height="25px" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="id" DataNavigateUrlFormatString="videoplay/mediaplayer.aspx?id={0}"
DataTextField="video_title" ShowHeader="False" Target="_blank" />
<asp:BoundField DataField="video_datetime" Visible="False" />
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="Image3" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridView6_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer)
{
Image strimage = (Image)e.Row.Cells[2].FindControl("image3");
strimage.ImageUrl = "http://localhost/oa/image/new5.gif";
}
}
前台代码:
<asp:GridView ID="GridView6" runat="server" AutoGenerateColumns="False" ShowHeader="False" BorderWidth="0px" Width="100%" OnRowDataBound="GridView4_RowDataBound" BorderStyle="None" OnDataBound="GridView6_DataBound">
<RowStyle Height="25px" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="id" DataNavigateUrlFormatString="videoplay/mediaplayer.aspx?id={0}"
DataTextField="video_title" ShowHeader="False" Target="_blank" />
<asp:BoundField DataField="video_datetime" Visible="False" />
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="Image3" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
解决方案 »
- vs断点调试网站项目出问题了, 求助.
- webbrower怎么获取HEAD及CONTENT信息
- (winfrom)在c#中treeview控件关于checked的问题
- 一哥们呼吁大家抵制日货,打道小日本,散了100分,我也声援一下,当把爱国青年,散100分.
- 在用C#开发程序时,有没有像VB。NET中的“模块”,在里面定义一些公用的变量。我是新手,请指教
- 俄罗斯方块单机对打多线程解决方法,大家有什么好的方法?
- Dictionary 查找相近的两个值。
- 重大问题!
- 今天发傻,有个问题实在不明白,看这个 Encoding ASCII = Encoding.ASCII;
- 《c#完全手册》的url,大家不用去跟贴!
- 那个简单正则
- HttpWebRequest+线程+异步控制,请牛人进来解答
====》OnRowDataBound="GridView6_RowDataBound"
GOOD
strimage.ImageUrl = "~/oa/image/new5.gif";
这样会省去很多麻烦。。