ASP MVC C# Cascading dropdown using single table - c#

I have a single oracle table with 5 columns and I need to create 5 cascading dropdown lists on the MVC view page, using combination of Razor and jquery. I got the first dropdown ok which comes from the Model passed on to the view. Having trouble figuring out the 2nd dropdown and after.
Any sample code or examples would be appropriated
Thanks
Mike

This is resolved. I ended up using jquery+ajax to make cascaded calls to the controller with each call passing the previous dropdown boxes values and returning a selectList of items from the DB.
Thanks

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!

dropdown list selected index changed razor

I am using razor view engine(cshtml) outside of mvc framework. i.e only view is converted to cshtml format.
I make all database calls using webmatrix and construct cshtml view.
Although, now i want to fire dropdown list selected change event which will set or fill contents of another dropdown list on the same page.
Currently I use dropdown list using
#HTML.DropdownList("ID",List)
on the selectedindex change of dropdown, i wish to check it's value and then decide on whether or not to populate second dropdown.
How can I do it in this scenario? Remember, no mvc framework, hence no access to models or mvc specific methods.
when the dropdown list is rendered in the browser, it simply becomes a HTML tag and you can use vanilla javascript or frameworks like jQuery to check the item selected and load the next dropdown.
Sample:
$( "#myselect option:selected" ).text();

To create textboxes in cshtml for List<string> in my model

am really new to MVC, i was web form developer but i happened to get involved in a project developed using MVC.
My view looks like this, 5 textboxes to enter values (stored as a List), when added will be displayed in a grid on the same view, gird has a edit and delete button. when user clicks on edit button the list of values will appear in each textboxes for the user to edit the values.
My Model has List Values.
Please shed some insight on how to achieve this scenario.
Thank you,

c# MVC3 Binding IEnumerable Model to table

I'm working on a university project and trying to learn MVC3 at the same time. I have a shopping basket style page with a table that shows the items. The model contains a list of products purchased.
I can display the products in a table via looping through the Model and displaying, however I need to implement a way to update the quantities. I currently have the quantities displayed in a HTML.TextBox which can be amended, but when I change the value it's not represented as such in the model.
Could somebody please advise how I could do this.
Thanks.
To update the model, you have post the edited values back to the server. To populate the model values in a text box, you can use the Html.EditorFor extension method and Pass in the lambda expression pointing to the quantity property. You can put the shopping cart controls within an HTML form control with an action of "post" and target of the controller route which will update the model. These are very basic operations in Asp.Net MVC, and you should be able to see how it is done in www.asp.net/MVC
Please do some research before posting your questions in the forum.

asp:Repeater and ActionLink

Am I able to use asp:Repeater and Html.ActionLink together for creating a dynamic menu? Or is there any other methods that I can use it?
Note: I'm getting the menu list from SQL.
I'm going to assume you are using ASP MVC 1 or 2 if you're using HTML.ActionLink. If that is the case, what you'll want to do is pass your list of items to the view through your Model or ViewModel and in the view, create a for each loop to display the items instead of using a repeater control.
Another option is to create a partial view that you pass your list of menu items to and create the for each loop in there then render the partial where ever you need to show your menu.
if you put the menu in the Master Page it will automatically show up every where.
I think you can, there are a lot of information on the web about how to use asp controls in MVC code. also, MVC seems to have its own repeater: http://davidhayden.com/blog/dave/archive/2009/04/07/ASPNETMVCControlsASPNETMVCFuturesRepeaterControlExample.aspx

Categories

Resources