Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to load the database value to the text box corresponding dropdown list. i am using

C#
<script>
 $(document).ready(function () {
            $(".ddl").change(function () {
                $(this).next("input.text").val($(this).val());
            });
        });
</script>



(html coade)
C#
@Html.DropDownListFor(model => model.SupplierId, (SelectList)(ViewData["SupplierId"]), "[ -- Please Select --]", new {@class="ddl", style = "width:310px; Height:30px" })
       
    <input id="myText" class="text" />


but it should not pick value from database.how can i load value in tex box?
Posted
Updated 5-Apr-14 20:22pm
v2

1 solution

See in this article we have done different types of databinding in dropdownlist,
1. Manual Binding like Gender (Male, Female)
2. Database binding from from sql to dropdownlist that is Country binding
3. Using Jquery and sql with filteration country and state binding state and city

For that you have read carefully all of things in this artile which will help you a lot. Hope so

Dropdownlist, Cascading Dropdown[^]
 
Share this answer
 
Comments
Dew Drops 7-Apr-14 0:40am    
Thanks for your reply, but i dont get any solution to load value in text box corresponding dropdown list.
[no name] 7-Apr-14 1:11am    
And my point was to see jquery and sql uses of mvc in that article

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