You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello I am new to jtable and like to improve programming skill but i am stuck on dropdown function and unable to display inside ADD/EDIT form . It come out weird value of dropdown is "undefined" . If i manual hardcore for options of Juice name will not issue and working fine.
Below is my code:
In controller part:
public JsonResult GetJuiceLists()
{
try
{
SelectList listJuice;
var sql = "SELECT JUICE_ID,JUICE_NAME FROM JUICE";
listJuice = new SelectList(SqlDbContext.getDropdownList(sql), "Value", "DisplayText");
return Json(new { Result = "OK", Options = listJuice}, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
public List<ViewModels.Dropdown_VM> getDropdownList(string sql)
{
try
{
var list = new List<ViewModels.Dropdown_VM>();
ConnOpen();
SqlCommand SQLcmd = new SqlCommand(sql, _SQLconn);
SQLcmd.CommandTimeout = 30;
SQLcmd.CommandText = sql;
SQLcmd.Connection = _SQLconn;
SqlDataReader dr = SQLcmd.ExecuteReader();
while (dr.Read())
{
list.Add(new ViewModels.Dropdown_VM
{
Value = dr.GetInt32(0),
DisplayText = dr.GetString(1)
}
);
};
return list;
}
catch (Exception exc)
{
throw exc;
}
finally
{
ConnClose();
}
}
Hello I am new to jtable and like to improve programming skill but i am stuck on dropdown function and unable to display inside ADD/EDIT form . It come out weird value of dropdown is "undefined" . If i manual hardcore for options of Juice name will not issue and working fine.
Below is my code:
In controller part:
In javascript part :
Can someone has any experience with that issue? Thank you so much.
The text was updated successfully, but these errors were encountered: