是否可以在GridView中以AutoGenerateColumns
模式顯示圖像?我tryed這一個ASP.Net GridView顯示圖像
private void LoadEventLog(string servicesName)
{
var bmp = new Bitmap(32, 32);
using (var g = Graphics.FromImage(bmp))
{
g.Clear(Color.Purple);
}
var logs = ServiceHelper.GetEventLogs(servicesName)
.Select(x => new {x.MachineName, x.TimeGenerated, Category = GetCategory(x.Category), x.Message, Img=bmp })
.Take(100)
.ToArray(); //
ServicesGrid.DataSource = logs;
ServicesGrid.DataBind();
}
ASPX:
<asp:GridView ID="ServicesGrid" OnRowDataBound="ServicesGrid_OnItemDataBound"
OnPageIndexChanging="ServicesGrid_OnPageIndexChanging"
AutoGenerateColumns="true" runat="server" AllowPaging="True" />
,但它不工作。