Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
namespace tableshow.Controllers
{
    public class TableShowController : Controller
    {
        private TableShowEntities db = new TableShowEntities();
        
        public ActionResult show()
        {
            ViewBag.TableShowsData = db.TableShows.ToList();
            return View();
        }
    }
}

VIEW:
HTML
@model tableshow.Models.TableShow

@{
    ViewBag.Title = "show";
}

<p>
    @Html.DropDownListFor(
    Model => Model.Name, 
    new SelectList(
        ViewBag. TableShowsData as System.Collections.IEnumerable, 
        "Id","Name"),
            "Select a Student", 
            new { @id = "ddlNames" }
            )
</p>

MODEL:
C#
namespace tableshow.Models
{
    using System;
    using System.Collections.Generic;

    public partial class TableShow
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
    }
}
Posted
Updated 18-May-15 1:26am
v2
Comments
.net bigner 18-May-15 7:17am    
When i select any name in dropdown then corresponding address should be show in TextBox.

1 solution

Try something Like that
JavaScript
$('#your-select').change(function() {
    var Id= 'Get value if For your name';
    $.ajax({
      url:'url which gives you address',
      data:Id,
      success: function (result) {
// here change value of address
}

});

C#
Public JsonResult GetAddressById(int Id)
{
return AddressById;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900