passing data from one action to another MVC asp.net
-
i am receiving Emplid in this action,
public ActionResult showDDL(int? EmplID = null)
{
ViewBag.EmplID = EmplID;
if (EmplID == null)
{
IEnumerable EmployeeAtd_2 = DataContext.GetAtdRecord_Sp(0).ToList();
return View(EmployeeAtd_2);
}
else if (EmplID != null)
{
IEnumerable EmployeeAtd_2 = DataContext.GetAtdRecord_Sp(EmplID).ToList();
return View(EmployeeAtd_2);
}return View(); }
View:
@{
var grid = new WebGrid(ViewData.Model, defaultSort: "EmplID", rowsPerPage: 20);
}
@if (Model.Count > 0)
{@grid.GetHtml(columns: grid.Columns(
grid.Column("EmplID", "Employee ID"),
grid.Column("EmplName", "Employee Name"),
grid.Column("ShiftID", "Shift ID"),
grid.Column("DateVisited", "Date of Visit"),
grid.Column("InTime", "In Time"),
grid.Column("TimeOut", "Time Out"),
grid.Column("OverTime", "Over Time"),
grid.Column("TotalWorkingTime", "Total Working Time")
))using (Html.BeginForm("ToExcel", "Home", FormMethod.Get))
{
<button type="submit" class="button_form button_download" >Download in Excel</button>
}}
else
{No Data Found
}
In same View you can see, button DOWNLOAD IN EXCEL, i want to pass this emplID to ToExcel method
public ActionResult ToExcel(int? empid )
{
var DataContext = new EmployeeRecordDataContext();var grid = new GridView(); grid.DataSource = DataContext.GetAtdRecord\_Sp(null).ToList(); grid.DataBind(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=AttendanceSheet.xls"); Response.ContentType = "application/ms-excel"; Response.Charset = ""; StringWriter sw = new StringWriter(); Syste
-
i am receiving Emplid in this action,
public ActionResult showDDL(int? EmplID = null)
{
ViewBag.EmplID = EmplID;
if (EmplID == null)
{
IEnumerable EmployeeAtd_2 = DataContext.GetAtdRecord_Sp(0).ToList();
return View(EmployeeAtd_2);
}
else if (EmplID != null)
{
IEnumerable EmployeeAtd_2 = DataContext.GetAtdRecord_Sp(EmplID).ToList();
return View(EmployeeAtd_2);
}return View(); }
View:
@{
var grid = new WebGrid(ViewData.Model, defaultSort: "EmplID", rowsPerPage: 20);
}
@if (Model.Count > 0)
{@grid.GetHtml(columns: grid.Columns(
grid.Column("EmplID", "Employee ID"),
grid.Column("EmplName", "Employee Name"),
grid.Column("ShiftID", "Shift ID"),
grid.Column("DateVisited", "Date of Visit"),
grid.Column("InTime", "In Time"),
grid.Column("TimeOut", "Time Out"),
grid.Column("OverTime", "Over Time"),
grid.Column("TotalWorkingTime", "Total Working Time")
))using (Html.BeginForm("ToExcel", "Home", FormMethod.Get))
{
<button type="submit" class="button_form button_download" >Download in Excel</button>
}}
else
{No Data Found
}
In same View you can see, button DOWNLOAD IN EXCEL, i want to pass this emplID to ToExcel method
public ActionResult ToExcel(int? empid )
{
var DataContext = new EmployeeRecordDataContext();var grid = new GridView(); grid.DataSource = DataContext.GetAtdRecord\_Sp(null).ToList(); grid.DataBind(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=AttendanceSheet.xls"); Response.ContentType = "application/ms-excel"; Response.Charset = ""; StringWriter sw = new StringWriter(); Syste
And what has this got to do with databases? You'll stand more chance of getting an answer if you post your question in the correct forum[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer