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 TrivediRank #16 · 50.3K reputationPosted Mar 1, 2015, 9:40 PM EST
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 SinghRank #643 · 3.7K reputationPosted Mar 1, 2015, 9:05 PM EST
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 BansalRank #142 · 15.9K reputationPosted Mar 1, 2015, 8:59 PM EST
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
Sweta Sinha53 reputationPosted Mar 1, 2015, 9:19 PM EST
This is my code:-
Sweta Sinha53 reputationPosted Mar 1, 2015, 9:48 PM EST
Actually the list from where I was searching contained upper case letters and i was searching with lower case letters.I did the change.
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 1, 2015, 9:54 PM EST
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
Anupam SinghRank #643 · 3.7K reputationPosted Mar 1, 2015, 9:55 PM EST