Question : .aspx.cs code for adding a textbox entry to "[contains(title, 'TextboxEntry']"

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.
Thank you
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
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;
            xmlDataSource1.DataBind();

            dtlDisplay.DataSource = xmlDataSource1;
            dtlDisplay.DataBind();

Answer : .aspx.cs code for adding a textbox entry to "[contains(title, 'TextboxEntry']"

Do you code compile?

If not one error can be found in the statement assigning to you "In" variable.
To be valid this should be: "[contains(title, '" + SearchText + "')]";

...but an even better alternative would be: "[contains(translate(title, 'ABCDEF...VWXYZ', 'abcdef...vwxyz') , '" + SearchText.ToLower() + "')]";
since this will make your search case insensitive.
Random Solutions  
 
programming4us programming4us