Hi,
I have a search box and want to search a string from a string.i.e,
Suppose, str[]= abf,fghi,acb,stabu
and if I search for "ab",then it should display "abf" and "stabu"
My Code:-
List selectedValues = new List();
foreach (string str in completeList)
{
if(str.Contains(filterWith)) //filterWith is the sequence of characters to be searched
selectedValues.Add(str);
}
Jignesh TrivediPosted Mar 2, 2015, 2:40 AM
Hi,
Agree with Anupam, using the LINQ to object you can find search result.
try...
string[] str= new [] {"abf","fghi","acb","stabu"};
var k = str.Where(p => p.IndexOf("ab") >= 0).ToList();
hope this will help you.
Anupam SinghPosted Mar 2, 2015, 2:55 AM
Jignesh TrivediPosted Mar 2, 2015, 2:54 AM
Hi,
Can you please share example data?
and you want to search only by name right?
here you are searching on combination of roll, name and pNo
Sweta SinhaPosted Mar 2, 2015, 2:48 AM
Actually the list from where I was searching contained upper case letters and i was searching with lower case letters.I did the change.
Sweta SinhaPosted Mar 2, 2015, 2:19 AM
This is my code:-
Anupam SinghPosted Mar 2, 2015, 2:05 AM
Can you post your complete code:
this code looks fine , if you have string array as
string[] str= anew [] {"abf","fghi","acb","stabu"};
and want to search "ab"
you can get results using string[] results=str.Where(s=>s.Contains("ab")).ToArray();
Rahul BansalPosted Mar 2, 2015, 1:59 AM
http://www.aspsnippets.com/Articles/AJAX-AutoCompleteExtender-Example-in-ASPNet.aspx
http://www.codeproject.com/Articles/71338/Using-the-AutoComplete-Extender-to-Automatically-P
http://www.ajaxcontroltoolkit.com/AutoComplete/AutoComplete.aspx