Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.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# 在GridView数据字段中追加文本_C#_Asp.net_Webforms - Fatal编程技术网

C# 在GridView数据字段中追加文本

C# 在GridView数据字段中追加文本,c#,asp.net,webforms,C#,Asp.net,Webforms,我正在尝试在我的ASP数据字段中追加文本: <asp:BoundField DataField='"https://media.expedia.com" + thumbNailUrl' HeaderText="Image" /> 然而,这是行不通的。还有其他方法吗? <asp:BoundField DataField="thumbNailUrl" HeaderText="Image" /> protected void OnRowDataBound

我正在尝试在我的ASP数据字段中追加文本:

<asp:BoundField  DataField='"https://media.expedia.com" + thumbNailUrl' HeaderText="Image" />

然而,这是行不通的。还有其他方法吗?


<asp:BoundField DataField="thumbNailUrl" HeaderText="Image" />       

protected void OnRowDataBound(object sender, EventArgs e)
{
    var ea = e as GridViewRowEventArgs;
    if (ea.Row.RowType == DataControlRowType.DataRow)
    {
        var d = ea.Row.DataItem as DataRowView;
        var ob = d["thumbNailUrl"];
        if (!Convert.IsDBNull(ob))
        {
            var cell = ea.Row.Cells[x];
            cell.Text = String.Format("https://media.expedia.com{0}", ob.ToString());
        }
    }
}
RowDataBound上受保护的void(对象发送方,事件参数e) { var ea=e作为GridViewRowEventArgs; if(ea.Row.RowType==DataControlRowType.DataRow) { var d=ea.Row.DataItem作为DataRowView; var ob=d[“thumbNailUrl”]; 如果(!Convert.IsDBNull(ob)) { var cell=ea.Row.Cells[x]; cell.Text=String.Format(“https://media.expedia.com{0},ob.ToString()); } } }

RowDataBound上受保护的void(对象发送方,事件参数e)
{
var ea=e作为GridViewRowEventArgs;
if(ea.Row.RowType==DataControlRowType.DataRow)
{
var d=ea.Row.DataItem作为DataRowView;
var ob=d[“thumbNailUrl”];
如果(!Convert.IsDBNull(ob))
{
var cell=ea.Row.Cells[x];
cell.Text=String.Format(“https://media.expedia.com{0},ob.ToString());
}
}
}

使用
DataFormatString

<asp:BoundField DataField="thumbNailUrl" DataFormatString="https://media.expedia.com/{0}" HeaderText="Image" />

使用
DataFormatString

<asp:BoundField DataField="thumbNailUrl" DataFormatString="https://media.expedia.com/{0}" HeaderText="Image" />


我也会试试这个,并告诉你这是怎么回事。公平地说,这个评论确实解决了这个问题。我也会尝试一下,让你知道这是怎么回事。公平地说,这一评论确实解决了这个问题。