Anmol Bali
Anmol Bali

Reputation: 11

In MVC, How can i navigate data through model object in View dynamically?

I want to get person details based on id through Model only. I have create a ModelView class in which i have person detail's properties and a method, GetList which is returning list object of all persons data.

Once i got that list data passed from controller to View, I now want to show person's data based on the Id entered in textbox and appear the rest of the details in other textboxes on tab out of first textBox.

For this i don't want to go to controller again because i have all the data on View, so how do i filter data on View only.

Could anyone help me in doing this?

Upvotes: 1

Views: 167

Answers (1)

nikhil kandalkar
nikhil kandalkar

Reputation: 181

For this you can use following approach :

  1. you fill all users data in controller with respect to userid.
  2. in your view at first you just display empty userid text box.
  3. after enter userid value in text box you can write change event of that text box by jquery as :

    $('#IdOfTextBox').change(function(){ 
      //write your hide and show and data filling logic here
    }); 
    

Upvotes: 1

Related Questions