views:

1272

answers:

5

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?

A: 

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>
A: 

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.

Scott
What do you get from the service if you call it directly?
Bryant
A: 

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.

Joel
+1  A: 

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

Joel
A: 

I tried the below and worked for me:

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