我使用ajax向下拉列表附加四个值,目前这些值不以逗号分隔我希望值以逗号分隔显示,并且从下拉列表中选择值后,只有一个值应该是可见的。 我的意思是当选择任何下拉值时,当前值看起来像这样。 '127Coil Wt1KGS'.IT应该像'127,Coil Wt,1,KGS'一样可见。在选择任何下拉值后,它应该像'Coil Wt'一样只能在下拉位置看到。
的Ajax
$(function () {
$("#Certific").click(function (event) {
$.ajax({
type: "POST",
url: "TDC.aspx/GetCertificate",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
var Certific = $("[id*=Certific]");
$.each(r.d, function () {
Certific.append($("<option></option>").val(this['CE_VAL']).html([this['CE_VAL'], this['CE_DESC'], this['CE_SUB_VALUE'], this['CE_SUB_DESC']]));
});
}
});
});
});
C#
public static List<Certificate> GetCertificate(){
string connStr = ConfigurationManager.ConnectionStrings["abc"].ToString();
OracleConnection objconn = new OracleConnection(connStr);
string prop_name, tdc_property = "", qry = "";
qry = "SELECT CE_VAL,CE_DESC,CE_SUB_VALUE,CE_SUB_DESC from code ";
OracleCommand objFetchCmd = new OracleCommand(qry, objconn);
List<Certificate> Certificate = new List<Certificate>();
objconn.Open();
OracleDataReader ReadData = objFetchCmd.ExecuteReader();
while (ReadData.Read()){
Certificate.Add(new Certificate{ CODE_VALUE = ReadData["CE_VALUE"].ToString(),CODE_DESC = ReadData["CE_DESC"].ToString(), CODE_SUB_VALUE = ReadData["CE_SUB_VALUE"].ToString() , CODE_SUB_DESC = ReadData["CE_SUB_DESC"].ToString() });
}
objconn.Close();
return Certificate;
}
任何想法都会受到赞赏。