Click here to Skip to main content
16,019,957 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
This's my Location table list

chennai, mumbai, pune
chennai, mumbai
mumbai, cochin
delhi, bangalore
chennai
bangalore, chennai

For examples : Naukri, Monster jobportal website in location search category


If am give the input values for chennai, mumbai means i want list out the chennai and mumbai list values in this datalist

how to split the textbox values please find out and send the coding path in asp.net

by

Bala
Posted

Looks like you can just do a String.Split on the textbox value. Check out msdn for more info: http://msdn.microsoft.com/en-us/library/system.string.split.aspx[^]

Good luck!
 
Share this answer
 
Comments
Bala Selvaraj 17-Apr-12 4:59am    
hi sir

I already use the coding path but i didnt got output. I send my coding please check the coding if error means please alter the coding and send me sir

coding in asp.net

string gh;
gh = lbllocat.Text.Trim();
StringBuilder sb = new StringBuilder();
if (gh != "" && gh != null)
{
string srch = "";

string[] ghsplit = gh.Split(',');
for (int i = 0; i < ghsplit.Length; i++)
{
string ghmultiple = ghsplit[i];
if (srch == "")
{
//srch = ghmultiple.ToString();
srch = ghmultiple[i].ToString().Trim();
//srch = "@loCat like '%" + ghmultiple.Trim() + "%'";
bind_KeysrchFunction(lblkey.Text.Trim(), srch.Trim(), lblsrhcat.Text.Trim(), lblsrhexp.Text.Trim(), lblminsal.Text.Trim(), lblmaxsal.Text.Trim(), lblcomp.Text.Trim(), lblrole.Text.Trim(), lblfresh.Text.Trim(), lblsort.Text.Trim(), lblrefsearch.Text.Trim());
}
else
{
srch = srch + ',' +ghmultiple[i].ToString().Trim();
//srch = gh[i].ToString().Trim();
srch = srch + "or like '% ','" + ghmultiple.Trim() + "%'";
bind_KeysrchFunction(lblkey.Text.Trim(), srch.Trim(), lblsrhcat.Text.Trim(), lblsrhexp.Text.Trim(), lblminsal.Text.Trim(), lblmaxsal.Text.Trim(), lblcomp.Text.Trim(), lblrole.Text.Trim(), lblfresh.Text.Trim(), lblsort.Text.Trim(), lblrefsearch.Text.Trim());
}
}
if (srch != "")
{
sb.Append("and(" + srch + ")");
}
}
Hey,


Just use the code!!.

Ex...
string sLocation="chennai, mumbai, pune";

string[] sArrLocation=sLocation.split(new char{','});

Then you will get collection of the location into sArrLocation.

I hope this will help you.


Thanks
Enjoy the Code.........
 
Share this answer
 
Comments
Bala Selvaraj 17-Apr-12 5:16am    
hi
I try this code

string sLocation = txtLocation.Value.ToString();
string[] sArrLocation = sLocation.Split(',');
for (int i = 0; i < sArrLocation.Length; i++)
{
sArrLocation[i] = Convert.ToString(sLocation);
bind_KeysrchFunction(lblkey.Text.Trim(), sLocation.ToString().Trim(), lblsrhcat.Text.Trim(), lblsrhexp.Text.Trim(), lblminsal.Text.Trim(), lblmaxsal.Text.Trim(), lblcomp.Text.Trim(), lblrole.Text.Trim(), lblfresh.Text.Trim(), lblsort.Text.Trim(), lblrefsearch.Text.Trim());
}


But I give the input value chennai means i got result the chennai list
totally 12 chennai list

and i give the another input value chennai, mumbai means i got result to match the chennai, mumbai list only. But i want totally chennai list and mumbai list also. please send the coding.for example; naukri, monster jobportal website the same location category.

By

Bala
Arav Pradeep Gupta 17-Apr-12 5:34am    
I am not sure what basically you want but as I understand some suggestions to do this task.

Why are spiting the locations into the franthand(C#) just send whatever string you got as input param like (mum,chann,etc) and use this into the Sql Query using IN keyword.

THIS CAN WE - manage from backend easily no need looping If you want couple of locations to be filter in search list.It reduce the DB call.

Looking forward your feedback.
Bala Selvaraj 17-Apr-12 5:46am    
Hi sir

I try this sql stored procedure also

this's syntax

select j.Location from jobdetails j with (nolock)
where j.Location like '%' +@loCat+ '%'


select j.Location from jobdetails j with (nolock)
where j.Location in (@loCat)

But , i didnt got output
Bala Selvaraj 17-Apr-12 5:25am    
hi
replay me sir

By

Bala
Bala Selvaraj 17-Apr-12 5:53am    
hi sir

Any idea from this task?

By

Bala

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900