Jaima Joseph

Jaima Joseph

  • NA
  • 94
  • 107k

How to add adropdownlist dynamically in MVC?

Jan 3 2014 2:39 AM

Hii,

In my application I haveto add a row to a table dynamically and after entering data into the columns of that row,onclick of save the newly added row data should be saved into databaseRight now I have added one row to my table using following javascript

$("#myButton").click(function () {


// Create elements dynamically


var newRow = '<tr>'+


'<td><input type="text" id="SupplierId" name="SupplierId" style="width:100px;" /></td>' +


'<td><input type="text" id="SKU" name="SKU" style="width:100px;" /></td>' +


'<td><input type="text" id="Price" name="Price" style="width:75px;" /></td>' +


'<td><input type="text" id="Validity" name="Validity" style="width:75px;" /></td>' +


'<td><input type="text" id="Quantity" name="Quantity" style="width:75px;" /></td>' +


'<td><input type="text" id="CreditId" name="CreditId" style="width:75px;" /></td>' +


'<td><input type="text" id="DeliveryDate" name="DeliveryDate" style="width:75px;" /></td>' +


'<td><input type="text" id="ETA" name="ETA" style="width:75px;" /></td>' +


'<td><input type="text" id="CommModeId" name="CommModeId" style="width:100px;" /></td>' +


'</tr>';






// Add the new dynamic row after the last row


$('#myTable tr:last').after(newRow);


Now my issue is,all the td columns in the above code is text box,In my application I want some tds as dropdownlists and it should allow to select data from database while clicking on it

Can we implement this?Is there any javascript for this?

Please Help

Thanks in advance


Answers (3)