Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do following(for onchange event of DropDownList):</p> <pre><code>@Html.DropDownList("ProductName", ViewData["ProductName"] as SelectList, "-Select Product-", new { onchange = "doFunction();" }) </code></pre> <p><strong>javascript:</strong></p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { doFunction(); }); function doFunction() { var PassVal = $("#ProductName").val(); //It has dropdownlist's selected value. if (PassVal != '') { //Do Ajax operations to load data in GridView(On Same Page). $.ajax({ url: '&lt;CONTROLLER/ACTIONANME&gt;', //Specify Actionname in controller from which you will get data. type: "POST", data: { ProductName: PassVal }, dataType: "html", success: function (data) { $("#GridView").empty(data); //empty gridview $("#GridView").html(data); //Load data to gridview }, error: function () { alert("No Records Found"); } }); } } &lt;/script&gt; </code></pre> <hr> <p><strong>Or On button click</strong></p> <pre><code>@Html.DropDownList("ProductName", ViewData["ProductName"] as SelectList, "-Select Product-") &lt;input type="button" id="btnSubmit" value="Submit"/&gt; </code></pre> <p>script:</p> <pre><code> $('#btnSubmit').click(function(){ var PassVal = $("#ProductName").val(); //It has dropdownlist's selected value. if (PassVal != '') { //Do Ajax operations to load data in GridView(On Same Page). $.ajax({ url: '&lt;CONTROLLER/ACTIONANME&gt;', //Specify Actionname in controller from which you will get data. type: "POST", data: { ProductName: PassVal }, dataType: "html", success: function (data) { $("#GridView").empty(data); //empty gridview $("#GridView").html(data); //Load data to gridview }, error: function () { alert("No Records Found"); } }); } }); </code></pre> <p>Ask me if you have any query.</p> <p><strong>Note</strong>: You can also use DropDownListFor for model binded dropdown.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload