Last post Aug 08, 2011 05:57 AM by chandrashekar
Member
47 Points
29 Posts
Aug 08, 2011 05:07 AM|jakub.rybacki|LINK
Hello
I have created XML Datasource with a query simmilar like in following topic: http://forums.asp.net/t/1258941.aspx/1?XPath+Contains+problem+
Unfortunately it always returns nothing. Can anyone tell me what is a source of this trouble? I am attaching xml structure and code behind
XML Structuture:
<?xml version="1.0" encoding="utf-8" ?> <Contactbook> <Contact Name="aaaaaa" Positon="" Mail="aaaaaaaaa"></Contact> </Contactbook>
Source Code:
if (txtSOSName.Text != "") { xmlSOSContactPeople.XPath = "/Contactbook[contains(./Contact/@Name,'" + txtSOSName.Text + "')]"; gridSOSContact.DataBind(); }
Star
8111 Points
2100 Posts
Aug 08, 2011 05:38 AM|chandrashekar|LINK
Hi, Try the below.
Since you are binding the contacts and you want to get the contacts whose name is eqal to the one entered in the text box.
if (txtSOSName.Text != "") { xmlSOSContactPeople.XPath = string.Format("/Contactbook/Contact[@Name='{0}']", txtSOSName.Text); gridSOSContact.DataBind(); }
Aug 08, 2011 05:48 AM|jakub.rybacki|LINK
This one will cause that Contact Name must be exactly like parameter. Instead I wolud like to use something like SQL LIKE (in case if somebody know only name etc.), so it requires usage of contains function.
That is not a solution to my problem
Aug 08, 2011 05:57 AM|chandrashekar|LINK
try
if (txtSOSName.Text != "") { xmlSOSContactPeople.XPath = string.Format("/Contactbook/Contact[contains(@Name,'{0}')]", txtSOSName.Text); gridSOSContact.DataBind(); }
Member
47 Points
29 Posts
XML Data Source - XPath Query - Contains Problem
Aug 08, 2011 05:07 AM|jakub.rybacki|LINK
Hello
I have created XML Datasource with a query simmilar like in following topic: http://forums.asp.net/t/1258941.aspx/1?XPath+Contains+problem+
Unfortunately it always returns nothing. Can anyone tell me what is a source of this trouble? I am attaching xml structure and code behind
XML Structuture:
Source Code:
Star
8111 Points
2100 Posts
Re: XML Data Source - XPath Query - Contains Problem
Aug 08, 2011 05:38 AM|chandrashekar|LINK
Hi, Try the below.
Since you are binding the contacts and you want to get the contacts whose name is eqal to the one entered in the text box.
Please try the answer for the post and finally Don't forget to click “Mark as Answer” on the post that helped you.
Member
47 Points
29 Posts
Re: XML Data Source - XPath Query - Contains Problem
Aug 08, 2011 05:48 AM|jakub.rybacki|LINK
This one will cause that Contact Name must be exactly like parameter. Instead I wolud like to use something like SQL LIKE (in case if somebody know only name etc.), so it requires usage of contains function.
That is not a solution to my problem
Star
8111 Points
2100 Posts
Re: XML Data Source - XPath Query - Contains Problem
Aug 08, 2011 05:57 AM|chandrashekar|LINK
try
Please try the answer for the post and finally Don't forget to click “Mark as Answer” on the post that helped you.