Click here to Skip to main content
15,894,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<asp:GridView ID="grd" runat="server" OnSelectedIndexChanged="grd_SelectedIndexChanged">
<columns> <asp:TemplateField>
<itemtemplate>
<asp:HyperLink ID="HyperLink2" runat="server" Target="_blank" NavigateUrl='<%#Eval("link") %>'>







<dataset>
<link>~/Default3.aspx</link>
<text>asdfoYYY
<date>2011/1/1

<dataset>
<link>~/Upload/DSC_0052.JPG</link>
<text>checkit
<date>2011/1/1

<dataset>
<link>~\Upload\id.txt</link>
<text>this if
<date>2011/1/1

<dataset>
<link>~\Upload\id.txt</link>
<text>this is asj asjfj
<date>2011/1/1

<dataset>
<link>~\Upload\id.txt</link>
<text>1212 is asj asjfj
<date>2012/12/12

<dataset>
<link>~\Upload\Landlordreferenceletter1.docx.doc</link>
<text>lanlord

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
binddata();
}

}
void binddata()
{



XDocument xmlDoc = XDocument.Load(Server.MapPath("File.xml"));

DateTime date = new DateTime(2012,12,12);


var queryWeek = from dataset in xmlDoc.Descendants("dataset")

select dataset.Element("link").Value;




grd.DataSource = queryWeek;

grd.DataBind();

}



ERROR=>>>>DataBinding: 'System.String' does not contain a property with the name 'link'.

TELL ME Reason
Posted

1 solution

Hi,

Did you tried the following:

C#
<asp:HyperLink ID="HyperLink2" runat="server" Target="_blank" NavigateUrl='<%# Container.DataItem %>'>


That is beacuse you bind a IEnumerable<string></string> to your DataSource, so you have just strings (and not any other kind of object).
Therefor the binding using Eval() does not work (beacuse you do not want to access a property of string but the string itself).

Hope this helps.

Best regards and happy coding,
Chris
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900