I have a project which has a Search textbox for the user to enter keyword(s) to retrieve from an
.xml page called rss.xml. In the .aspx.cs page I was instructed to do this by declaring a
string (sTemp) and sTemp = "[contains(title, 'asp')]" for example. However, I now need to replace the
'asp' with whatever the user inputs into the textbox. I've attached the back code that I'm using.
Any help would be GREATLY appreciated.
protected void btnSearch_Click(object sender, EventArgs e)
string In = string.Empty;
string SearchText = txtSearch.Text;
if (ddlSearchWhere.SelectedIndex == 0) -----this is from a dropdown list for the user to choose where they want their text searched----
In = "[contains(title,"+'txtSearch.Text')]";
if (SearchText != null)
SearchText = In;
//In = "[contains(title, '" + SearchText;
xmlDataSource1.DataFile = @"rss.xml";
xmlDataSource1.XPath = @"rss/channel/item" + SearchText;// + sTemp;
dtlDisplay.DataSource = xmlDataSource1;