3

Why am I getting a textbox that returns undefined list of variables?

When I run this code:

var query = (from tisa in db.TA_Info_Step_Archives
                 where tisa.ta_Serial.ToString().StartsWith(prefixText)
                 select tisa.TA_Serial.ToString()).Distinct().Take(Convert.ToInt32(count));

return query.ToList<string>().ToArray();

I get this XML file:

<string>200700160</string> 
  <string>200700161</string> 
  <string>200700162</string> 
  <string>200700163</string> 
  <string>200700164</string> 
  <string>200700170</string> 
  <string>200700171</string> 
  <string>200700172</string> 
  <string>200700173</string> 
  <string>200700174</string> 
  <string>200700175</string> 
  <string>200700176</string> 
  <string>200700177</string> 
  <string>200700178</string> 
  <string>200700179</string> 
  <string>200700180</string> 
  <string>200700181</string> 
  <string>200700182</string> 
  <string>200700183</string> 
  <string>200700184</string> 

BUT, the textbox returns a list of undefined....

Help please?

7 Answers 7

4

updated my ajax kit to version 1.0.10920 then changed my code to the following:

     foreach (DataRow dr in dt.Rows)
        {
            items.SetValue("\"" + dr["somenumber"].ToString() + "\"", i);
            i++;
        }

Late friday nights with .net is not fun. I have no life. :-P

1
  • I had the same kind of problem. Seems that adding quotes around items returned by ServiceMethod does the trick. Jan 20, 2015 at 20:54
1

I tried the code below and it worked for me:

items.SetValue("'"+dr["somenumber"]+"'", i);
0

It sounds like the problem isn't with the method, but with the way you are hooking up the autocomplete to the method... Is your Extender similar to the following:

<cc1:AutoCompleteExtender ID="Result" runat="server" TargetControlID="txtSearch" ServiceMethod="YourMethodHere"
    ServicePath="~/Service/YourWebServiceHere.asmx"     CompletionInterval="500"
    EnableCaching="false" CompletionListCssClass="AutoComplete_List"  CompletionSetCount="10">
</cc1:AutoCompleteExtender>
0

The Problem that I am seeing is that the AJAX library is looking at the numbers as integers. It needs to be looking at them as strings.

I have converted it to a string and still got nothing. I have to add some kind of character to the numbers to make their value now looked upon as a string. It is a horrible thing to do. But somewhere in the AJAX library for the autocomplete extender .js file, they don't look for integers. They only look for strings which needs to be looked at because their way of building is is flawed...

Scott.

1
  • What do you get from the service if you call it directly?
    – Bryant
    Oct 9, 2008 at 21:42
0

I've run into the same issue. I agree the issue definitely seems to be stemming around that we're using numbers here. As soon as I append an alpha to the end of a array item it works. I believe we've found a bug.

this kicks out the undefineds....

...
da.Fill(dt);
        string[] items = new string[dt.Rows.Count];
        int i = 0;
        foreach (DataRow dr in dt.Rows)
        {
            items.SetValue(Convert.ToString(dr["somenumber"]), i);
            i++;
        }
...

where as this loads the list just fine

...
da.Fill(dt);
        string[] items = new string[dt.Rows.Count];
        int i = 0;
        foreach (DataRow dr in dt.Rows)
        {
            items.SetValue(Convert.ToString(dr["somenumber"]+"foo"), i);
            i++;
        }
...

Seems like a bug to me.

0

There is a difference between toolkit dll versions.

In the updated version, one does not need to insert the "'"+ +"'", and it works fine. In version 1.0.10920, it is needed.

0

http://www.asp.net/ajax In this above link u will find AjaxControllToolkit just download it and add reference in ur application i am sure it will work fine. problem is u r working with very old AjaxControllToolkit so its not working ,work with AjaxControllToolkit 3.5 or 4.0.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.