C# 更改自动生成列的数据类型

C# 更改自动生成列的数据类型,c#,asp.net,gridview,C#,Asp.net,Gridview,我有一个自动生成列的Gridview。。。 问题是,数据类型都是imageurl 填充gridview时,url为标签格式 我可以将它们定义为templatefield,它可以工作,但要求是自动生成 我在MSDN上读到了这篇文章,但我不知道如何从这里开始 private void BUChecker_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) { } 您可以在其模板字段中更改此项。请参

我有一个自动生成列的Gridview。。。 问题是,数据类型都是imageurl

填充gridview时,url为标签格式

我可以将它们定义为templatefield,它可以工作,但要求是自动生成

我在MSDN上读到了这篇文章,但我不知道如何从这里开始

private void BUChecker_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
}

您可以在其
模板字段中更改此项。请参见
GridView
controls'。
请参阅以供参考

如果您不想使用模板字段,我认为您可以使用
RowDataBound
如下

protected void RowDataBound(Object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
        //find your cell suppose it is Cell 0
       string imgUrl=e.Row.Cells[0].Text;
       Image img = new Imge();
       img.ImageUrl =imgUrl;
       e.Row.Cells[0].Controls.Add(img);

    }
}
是一个较短的资源,可以与上面的资源一起使用。