Thursday, March 29, 2012

newbie: ItemDataBound and XPath

hey

asp.net 2.0

I have a DataList which has a XmlDataSource as its data source.

This code crash because I use XPath in the ItemDataBound event:
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs
e)
{
Label label = (Label)e.Item.FindControl("lblTitle");
label.Text = XPath("title").ToString();
label = (Label)e.Item.FindControl("lblStory");
label.Text = XPath("description").ToString();
}

Any suggestion how this should be done in a ItemDataBound event?

Jeff"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:eCAL$KttGHA.2160@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I have a DataList which has a XmlDataSource as its data source.
>
This code crash because I use XPath in the ItemDataBound event:
protected void DataList1_ItemDataBound(object sender,
DataListItemEventArgs e)
{
Label label = (Label)e.Item.FindControl("lblTitle");
label.Text = XPath("title").ToString();
label = (Label)e.Item.FindControl("lblStory");
label.Text = XPath("description").ToString();
}
>
Any suggestion how this should be done in a ItemDataBound event?
>
Jeff
>


Jeff look at this sample here at:-
http://www.msdner.com/forum/thread467894.html
Patrick

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:eCAL$KttGHA.2160@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I have a DataList which has a XmlDataSource as its data source.
>
This code crash because I use XPath in the ItemDataBound event:
protected void DataList1_ItemDataBound(object sender,
DataListItemEventArgs e)
{
Label label = (Label)e.Item.FindControl("lblTitle");
label.Text = XPath("title").ToString();
label = (Label)e.Item.FindControl("lblStory");
label.Text = XPath("description").ToString();
}
>
Any suggestion how this should be done in a ItemDataBound event?
>
Jeff
>

0 comments:

Post a Comment