Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 更改放置在GridTemplateColumn中的图像的ImageURL_C#_Asp.net_Image_Gridview_Telerik - Fatal编程技术网

C# 更改放置在GridTemplateColumn中的图像的ImageURL

C# 更改放置在GridTemplateColumn中的图像的ImageURL,c#,asp.net,image,gridview,telerik,C#,Asp.net,Image,Gridview,Telerik,我试图在gridview中显示图像,但是,在gridview中显示的列都是动态显示的而不是生成的 我已经看过这篇文章了,但对我来说似乎不起作用: 我拥有的是一个包含以下列的gridview: <Columns> <telerik:GridBoundColumn HeaderText="Custom1" HeaderStyle-VerticalAlign="Bottom" DataField="Custom1" SortExpression="C

我试图在gridview中显示图像,但是,在gridview中显示的列都是动态显示的而不是生成的

我已经看过这篇文章了,但对我来说似乎不起作用:

我拥有的是一个包含以下列的gridview:

    <Columns> 
        <telerik:GridBoundColumn  HeaderText="Custom1"   HeaderStyle-VerticalAlign="Bottom" DataField="Custom1" SortExpression="Custom1"/>
        <telerik:GridDateTimeColumn HeaderText="Custom2"   HeaderStyle-VerticalAlign="Bottom" DataField="Custom2" SortExpression="Custom2"/>
        <telerik:GridCheckBoxColumn  HeaderText="Custom3"   HeaderStyle-VerticalAlign="Bottom" DataField="Custom3" SortExpression="Custom3"/>
        <telerik:GridTemplateColumn HeaderText="Custom4" HeaderStyle-VerticalAlign="Bottom" DataField="Custom4"><itemtemplate><asp:Image runat="server" ID="Custom4_pic"/></itemtemplate></telerik:GridTemplateColumn>

任何提示都很好,谢谢

我已经解决了这个问题

我用GridImageColumns替换了模板列,然后在我的codebehind中,我将列添加到字符串类型的datatable中,然后使用图像处理程序,并将字符串设置到图像处理程序页面

dt = new DataTable();
// Do some stuff...
if (aProperty.WebControlType == EntityPropertyWebControlType.CheckboxYN || aProperty.WebControlType == EntityPropertyWebControlType.OptionYN)
{
    dt.Columns.Add("Custom" + ((i * 4) - 1).ToString(), typeof(bool));
    break;
}
else if (aProperty.WebControlType == EntityPropertyWebControlType.Date)
{
    dt.Columns.Add("Custom" + ((i * 4) - 2).ToString(), typeof(DateTime));
    break;
}
else if (aProperty.WebControlType == EntityPropertyWebControlType.Image)
{
    // Not sure what to do here...
    break;
}
else
{
    dt.Columns.Add("Custom" + ((i*4) - 3).ToString(), typeof(string));
    break;
}

// Do more stuff...

// Based on type I will set the values to equal something.. so for example
dr["Custom" + aProperty.LabelColumnNo.ToString()] = "Text" or bool or DateTime
// However I'm not sure what to do for Image...

// and then I return the datatable to be binded to the gridview