public static List <SelectListItem> getCustomers(Int64 pCustId) { List <SelectListItem> lstcustomers = new List <SelectListItem>(); DataTable dtcustomer = new DataTable(); dtcustomer = ProductMasterData.SelectCustomer(); lstcustomers.Add(new SelectListItem { Value = "0", Text = "---Select---" }); foreach (DataRow dr in dtcustomer.Rows) { if (pCustId.ToString() == dr["CustId"].ToString()) { lstcustomers.Add(new SelectListItem { Value = dr["CustId"].ToString(), Text = dr["Custname"].ToString(), Selected = true }); } else { lstcustomers.Add(new SelectListItem { Value = dr["CustId"].ToString(), Text = dr["Custname"].ToString() }); } } return(lstcustomers.ToList()); }
public static List <SelectListItem> getBlankCategory(Int64 pCustId) { List <SelectListItem> lstcategory = new List <SelectListItem>(); DataTable dtcustomer = new DataTable(); dtcustomer = ProductMasterData.SelectCustomer(); lstcategory.Add(new SelectListItem { Value = "0", Text = "---Select---" }); /* foreach (DataRow dr in dtcustomer.Rows) * { * lstcustomers.Add(new SelectListItem * { * Value = dr["CustId"].ToString(), * Text = dr["Custname"].ToString() * }); * }*/ return(lstcategory.ToList()); }