FILL THE VIEW BAG
ViewBag.toAccount = new SelectList(db.GetIEnumerableAccountDetails(userID, "SI"), "AccountID", "AccountName");
public IEnumerable
{
SqlConnection con = Getcon();
SqlCommand cmd = new SqlCommand("GetUserAccount", con);
cmd.Parameters.AddWithValue("@pSp", psp);
cmd.Parameters.AddWithValue("@puserID", userID);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
con.Close();
return dt.AsEnumerable().Select(row =>
{
return new AccountDetail
{
AccountID = Convert.ToInt32(row["AccountID"]),
AccountName = row["AccountName"].ToString()
};
});
}
No comments:
Post a Comment