MVC Telerik DropDownList Setting First item OnLoad - c#

I have a MVC Telerik DropDown List. I am getting the Data through Ajax Binding. On the Page Load I want the First SelectList Item to be Autopopulated. What is the best way of achieving this.
After Googling and educating how Telerik AjaxBinding works. I came to a conclusion that Ajax binding will activate the call only when the Dropdown is Clicked.
Best way of achieving my requirement?
Thank You

You could force the DropDownList to fetch its data when the page is loaded via the fill method
$('#ComboID').data().tComboBox.fill()
Or add that one value initially on the server side via the Items method.

Related

Is there any straight way to return the whole items of a Kendo DropdownlistFor using a single POST?

I'm using a kendo dropdownlistFor and populate it by items that a user is able to add. and I'm using a modal dialog which sends an ajax POST to the controller. Now my question comes forward.
Is there any straight way (not using HiddenFor, or tricky Js or Jq stuffs. instead using MVC or Kendo functions) to pass the whole items of this DropdownList to the controller?
What I have now, is a kendo dropdownlistfor and a property of List. the Post returns, of course, the selected item id.
Thanks in advance for any suggestion.
I am currently trying to do a similar thing with my project. As far as I have been able to discover there is no way to do this without having a JS function, ticket ongoing. However your case may be possible if I understand it correctly. The user passes in items to your dropdown correct? So if you were to save those items into a List and then pass that list into the controller it should work correctly. If you could give some of your code or a picture of your UI I may be able to give you a bit more direction. Hope this helps!

ASP Net Text box with Google like dropdown search values

I am looking for a textbox in C# which should work like dropdown search values when I type anything in the textbox. Those values will come from calling a method.. and I Should be able to select any of the values.
Do i need to use the asp dropdownlist or is there any other sample code available which could help me.
You should look into jQuery autocomplete feature.
http://jqueryui.com/autocomplete/
The ajax control toolkit provides Autocomplete extender to do just that. The control calls a method, which you specify, asynchronously and get all the values to be shown as an option. I would imagine these values would be retrieved when the page loads and will not be session specific so can be stored in a cache for faster retrieval.
http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx

Client-side binding of a datagrid to List<>

In my ASP.NET MVC Webb app, I want a page to hold a DataGrid with ButtonColumns. To this I have a List<> of items that I want to represent in the DataGrid. By use of a textbox, I want the app (on the client side) to search the List<> for items matching the text string (preferably with LINQ).
What does this really require? Can this be done simply with Javascript? Do I need AJAX?
Does anyone here have experience with this kind of solutions?
Thanks!
You want to create a ViewModel of your List. Have a Grid on your view. You can use JavaScript&AJAX or post back to filter the grid. Most grids have filters built in.
I suggest you start on a MVC tutorial to get you started.
See ASP.NET MVC 4 Datagrid

Asynchronously update asp.net repeater as and when data changes

I want an asp.net repeater control to update by itself as and when the actual data that it's pointing to, gets updated. I'm not looking for a solution where a button click happens and each time repeater(which is inside an updatepanel) is bound to a datasource.
Ex: In my page load, I have this
Page_Load(){
myRepeater.DataSource = ListOfStringObj;
myRepeater.DataBind();
}
Now, if at some point ListOfStringObj gets updated, then the repeater should reflect the changes without explicitly binding it again to the datasource.
Is this even possible? I'm not particular about repeater control here, it can be a gridview as well. If not can anyone please explain?
PS: Something of this sort is possible using Knockout js, which is based on MVVM
Thanks,
Sharath
I hope this MVVM for ASP.NET will help you to achieve this: asp.net MVVM

Dynamic Drop Down List ASP.net

How can I create a dynamic drop down list without using AutoPostBack. I ask because I just want to change the value of what the second drop down list displays and then the user clicks a button and it submits. But If I use AutoPostBack then it postbacks to page and runs code that shouldn't be run until that final box has been selected. (I use Postback in the other part of my program so using !IsPostBack isnt a option.) I looked at Javascript but ASP generates all of its controls names at runtime. What can I do? I have looked at the Ajax CascadingDropDown control but my problem with that is it contained in a XML file or a Database, I need this to be contained inside my Page. Any Ideas?
You can use the CascadingDropDown control from the AJAX Control Toolkit
Maybe this example will help? It's part of the ASP.NET AJAX Control Toolkit available here.
You can use AJAX to get the values for the second drop down list, based on the selected value of the first. Add a onchange event handler on the client-side to the first drop down list that makes the AJAX call and fills the second on success.

Categories

Resources