This is a migrated thread and some comments may be shown as answers.

[Solved] autocomplete textbox shows the value 'System.String[]'

1 Answer 101 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Borislav
Top achievements
Rank 1
Borislav asked on 14 Dec 2010, 09:25 PM
When the page loads the autocomplete textbox shows the value 'System.String[]' .

// simple List<string>
List<string> firstName = new List<string>();
firstName.Add("Bob");
firstName.Add("Bill");
firstName.Add("Denny");
firstName.Add("Dennis");
ViewData["firstname"] = firstName.ToArray();

// in view
<% Html.Telerik().AutoComplete()
 .Name("FirstName")
 .BindTo((IEnumerable<string>)ViewData["firstname"])
 .Filterable(f => f.MinimumChars(2).FilterMode(AutoCompleteFilterMode.StartsWith))
 .HighlightFirstMatch(true)
 .AutoFill(true)
 .HtmlAttributes(new { @style = "width:200px;" })
 .Render(); %>

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 15 Dec 2010, 01:57 PM
Hello Borislav,

This is expected behavior. When component is renderинг, it tries to retrieve value with ViewData.Eval(Component.Name), in order to preserve posted value. Hence if the array of items has the same name as the component, then it will be retrieved.

I will suggest you change the name of the array:

// simple List<string>
List<string> firstName = new List<string>();
firstName.Add("Bob");
firstName.Add("Bill");
firstName.Add("Denny");
firstName.Add("Dennis");
ViewData["firstnameArray"] = firstName.ToArray();

Best wishes,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Borislav
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or