LINQ to XML和GridView.ImageField

| 我想知道如何基于xml文档中的imageurl将图像添加到gridview。到目前为止,我有...
XDocument xmlDoc = XDocument.Load(Server.MapPath(\"XMLFile.xml\"));

var q = from c in xmlDoc.Descendants(\"Images\")
        where c.Element(\"PropertyId\").Value.ToString() == DropDownList1.SelectedValue.ToString()
        select new
        {
            Id = c.Element(\"PropertyId\").Value,
            Thumb = c.Element(\"ThumbUrl\").Value                
        };
GridView1.DataSource = q;
GridView1.DataBind();
哪个可以正常显示拇指字段中的URL,但不是显示此URL,我如何将其更改为图像字段?     
已邀请:
标记:
<asp:GridView runat=\"server\">
    <Columns>
        <ImageField DataImageUrlField=\"PhotoPath\" />
    </Columns>
</<asp:GridView>
后台代码:
string selectedValue =  DropDownList1.SelectedValue.ToString(); // cache it!
var q = from c in xmlDoc.Descendants(\"Images\")
        where c.Element(\"PropertyId\").Value.ToString() == selectedValue 
        select new
        {
            PhotoPath = c.Element(\"PhotoPath\").Value         
        };

GridView1.DataSource = q;
GridView1.DataBind();
你有什么问题?     

要回复问题请先登录注册