是否可以在 GridViewAutoGenerateColumns
模式下显示图像?我试过这个
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" />
但它不起作用。