Hi, Actually i need to populate a dropdownlist with data each time a button is clicked, In my code, i have this function method that adds in 2 textboxes and a dropdown list as an array each time a button is clicked, But the problem is I need to be able to populate the dropdownlist with data..
function AddCust() {
var m = $('#divcust input:last-child').attr('name');
var v = $('#divcust input:last-child').attr('name');
var c = $('#divcust input:last-child').attr('name');
var index = 0;
var index2 = 0;
var index3 = 0;
if (m != null && m.length > 0) {
index = m.split('custmodel.CustList[')[1].replace('].DrugName', '');
index2 = v.split('custmodel.CustList[')[1].replace('].Quantity', '');
index3 = c.split('custmodel.CustList[')[1].replace('].Dosage', '');
index++;
index2++;
index3++;
}
var html = '<table class=\"table table-striped table-bordered table-hover table-responsive\"><tr><td><label for=\"custmodel.CustList_' + index + '__DrugName\">DrugName</label>' +
'<input title=\"The Drug Name field is required\" required id=\"custmodel.CustList_' + index + '__DrugName\" class=\"text-box single-line\"' +
' type=\"select\" value=\"\" name=\"custmodel.CustList[' + index + '].DrugName\"></td>'+
'<td><label for=\"custmodel.CustList_' + index2 + '__Quantity\">Quantity</label>' +
'<input title=\"The Quantity field is required\" required id=\"custmodel.CustList_' + index2 + '__Quantity\" class=\"text-box single-line\"' +
' type=\"text\" value=\"\" name=\"custmodel.CustList[' + index2 + '].Quantity\"</td>' +
'<td><label for=\"custmodel.CustList_' + index3 + '__Dosage\">Dosage</label>' +
'<input required title=\"The Dosage field is required\" id=\"custmodel.CustList_' + index3 + '__Dosage\" class=\"text-box single-line\"' +
' type=\"text\" value=\"\" name=\"custmodel.CustList[' + index3 + '].Dosage\"></td></tr><table>';
$('#divcust').append(html);
};
Here is my table class
public class Drug
{
public string drugname {get;set;}
}