0
我有我想要生成我的電子郵件數據作爲圖像的列表視圖。 Follwing是我的代碼。如何在列表視圖中生成文本爲圖像ItemTemplate
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<asp:ListView ID="lvtest" runat="server"
CellPadding="0"
RepeatDirection="Horizontal"
GroupPlaceholderID="itemPlaceholdersp"
ItemPlaceholderID="itemPlaceholdersp" >
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholdersp" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<div class="accordionBg">
<h3><%# Eval("UserName") %></h3>
<h4>
<%# Eval("Designation").ToString() == "" ? "" : Eval("Designation") + "<br/>" %>
<%# Eval("Qualification").ToString() == "" ? "" : Eval("Qualification")+ "<br/>" %>
<%
Response.Clear();
int height = 100;
int width = 200;
Random r = new Random();
int x = r.Next(75);
Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bmp);
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.Clear(Color.Orange);
g.DrawRectangle(Pens.White, 1, 1, width-3, height-3);
g.DrawRectangle(Pens.Gray, 2, 2, width-3, height-3);
g.DrawRectangle(Pens.Black, 0, 0, width, height);
g.DrawString(Eval("Email").ToString(), new Font("Arial", 12, FontStyle.Italic),
SystemBrushes.WindowText, new PointF(x,50));
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
g.Dispose();
bmp.Dispose();
Response.End();
%>
</h4>
<p class="clear"></p>
</div>
<div class="accordion_content">
<div class="vertical_accordion_content">
<p><%# Eval("Description")%></p>
</div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
不過,這並不work.error發生的
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
請幫助我。