Multi Select Data List With C#
=========================================================
<select title="BuyerList" class="cmbbuyer" id="buyerid" style="height:30px;width:200px;font-size:12px;"> </select>
============================================================
Jquery
============================================================
Loadbuyer()
function Loadbuyer() {
var option = "";
$.ajax({
type: "POST",
url: base + "GreyInfo/BuyerList",
dataType: "JSON",
contentType: "application/json;charset=utf-8",
success: function (data) {
var content = '';
$.each(data, function (i, obj) {
content += '<option value="' + obj.BuyerID + '">' + obj.BuyerFullName + '</option>';
});
$("#buyerid option").remove();
$("#buyerid").multipleSelect('refresh');
$('#buyerid').append(content);
$("#buyerid").multipleSelect({
filter: true,
//isOpen: true
}, "uncheckAll");
},
error: function (a, b, c) { alert(formatErrorMessage(a, c) + "....loadCompany"); }
});
}
---------------------------------------------
Bind in Gird
function GetRequisitionDetailsForApproval(PackingAutoNo, PackingListID, UnitName) {
$('#gridReceiveInfo tr:gt(0)').remove();
$.ajax({
url: base + "Finish_Store_UI/LoadReceivePackingInfo",
type: "post",
dataType: "json",
contentType: "application/json",
data: JSON.stringify({ "PackingNo": PackingAutoNo }),
success: function (data) {
if (data.length > 0) {
//var j = 0;
//<select style="width:12em;" id ="txtFinishProcess" class="FinishProcess afterentergrid"></select>
var contentData = '';
$.each(data, function (i, obj) {
contentData += '<tr><td><select id="txtFinishProcess" style="width:12em;" class="FinishProcess"></select></td><td style="display:none">' + obj.OrderBookingID + '</td></tr>';
});
$('#gridReceiveInfo tr:gt(0)').remove();
$("#gridReceiveInfo").append(contentData);
$.ajax({
type: "POST",
url: base + "Finish_Store_UI/LoadFinishingProcess",
dataType: "JSON",
contentType: "application/Json; charset=utf-8",
success: function (data) {
var content = '';
$.each(data, function (i, obj) {
content += '<option value="' + obj.FinishProcecingID + '">' + obj.FinishProcecingName + '</option>';
//content += '<option style="text-align: left;" value="' + obj.FinishProcecingName + '">"' + obj.FinishProcecingName + '"</option>';
});
$(".FinishProcess option").remove();
$(".FinishProcess").append(content);
$(".FinishProcess").val("");
$(".FinishProcess").multipleSelect({
filter: true,
});
//$("#txtFinishProcess option").remove();
//$("#txtFinishProcess").append(content);
//$("#txtFinishProcess").val("");
//$("#txtFinishProcess").multipleSelect('refresh');
}
});
}
}).done(function () {
});
}
---------------------------------------
Get Data ID | Data Value
--------------------------------------
Single List::
-----------------
var buyerIDarray = $("#buyerid").multipleSelect('getSelects');
var buyerlistid = "";
if (buyerIDarray.length > 0) {
buyerlistid = buyerIDarray.map(function (cc) {
return cc;
}).join(',');
} //End
alert(buyerlistid);
-- End
Bind in Grid::
-----------------
var FinishProcess = row.children('td').eq(5).find(".FinishProcess:eq(0)").multipleSelect('getSelects'); //var respdept_array = $("#cmbRespDept").multipleSelect('getSelects');
var FinishProcessArray = "";
if (FinishProcess.length > 0) {
FinishProcessArray = FinishProcess.map(function (cc) {
return cc;
}).join(',');
}
==========================================================
#C ASP .NET MVC
==========================================================
public List<OrderCreateandReviseModel> BuyerList()
{
List<OrderCreateandReviseModel> lbdBuyertlist = new List<OrderCreateandReviseModel>();
string error = string.Empty;
QUERY query = new QUERY();
query.SQL = @"SELECT TOP (100) PERCENT ID, BuyerFullName
FROM dbo.tblBuyerList
ORDER BY ID";
dt = cls.GetDataTable253_Mymun(query, out error);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
OrderCreateandReviseModel loadBuyerlist = new OrderCreateandReviseModel();
loadBuyerlist.BuyerFullName = dt.Rows[i]["BuyerFullName"].ToString();
loadBuyerlist.BuyerID = dt.Rows[i]["ID"].ToString();
lbdBuyertlist.Add(loadBuyerlist);
}
}
return lbdBuyertlist;
}
=============================================================
No comments:
Post a Comment
I am Safiqul Islam Tuhin