0

I have a java script, i want to bind data table in variable available ?

<script>
   $(function () {
       *var available* = [

        ];
        $("#tags").autocomplete({
           source: availableTags
        });
   });
</script>

I have a data table which is as follows:-

ds = du.returnDataSet("proc", "SHOW_REFINE_SEARCH", Parameters, DbTypes, ParameterTypes, values, Lengths);
DataTable dt = new DataTable();
dt = ds.Tables[0];

the data table value comes in the form which are as follows:-

Zone_ID Zone_Name     Company_ID
1       Rajasthan          1
2       Madhya Pradesh     1
3       Maharashtra        1
4       Uttar Pradesh      1
5       Jammu and Kashmir  1
6       Gujarat            1

I want to bind zone_name in javascript string variable...

2 Answers 2

1

Use Linq to DataTable Use .AsEnumerable()

ds = du.returnDataSet("proc", "SHOW_REFINE_SEARCH", Parameters, DbTypes, ParameterTypes, values, Lengths);
DataTable dt = new DataTable();
dt = ds.Tables[0];
string[] zone_nameList = (from n in dt.AsEnumerable() select n.Filds<string>("zone_name")).ToArray();
Sign up to request clarification or add additional context in comments.

2 Comments

how to append zone_namelist in javascript variable
@PraveenSingh - You have to use WebMethod for this
0

There are other options with jQuery which you can use instead of using array you can use a web method.

You can go through this link

http://blog.nitinsawant.com/2011/09/integrating-jquery-ui-autocomplete-in.html

There are many question asked to SO all ready like

  1. Jquery autocomplete .NET WebMethod
  2. Jquery AutoComplete with database

You need to create a web method or generic http handler as use it as source for you auto complete.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.