Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i am calling store procedure from MVC, which returns single record only.

SP contains:

SQL
PROCEDURE [dbo].[GetMonthlyReport] @emplID INT = NULL,
	@month VARCHAR(50) = NULL
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	IF (@emplID IS NOT NULL AND @month IS NOT NULL) --If Block begins
	BEGIN
		SELECT *
		FROM MonthlyRecord
		WHERE Month = @month AND EmplID = @emplID
	END --If block ends
	ELSE --Else block begins
	BEGIN
		RETURN 0
	END --Else block ends
END

now it is selecting, empID, Overtime, Month, TotalDuration from MonthlyRecord View,

What i want to do is to put these fields in custom template e.g. HTML TABLE or List, like :

HTML
<table style="width:300px">
<tr>
<td>Employee ID</td>
<td>Month</td> 
</tr>
<tr>
<td>@empID</td>
<td>@Month</td> 
</tr>
</table>

something dynamic.

MVC Code:

Controller:

C#
public ActionResult Generated_PaySlip(int? emplID, String month) 
{
IEnumerable<GetMonthlyReportResult> PaySlip = DataContext.GetMonthlyReport(emplID, month).ToList();
return View(PaySlip);
}

View:
@using EmployeeAttendance_app.Models

Employee Pay Slip





Employee IDMonth
@empID@Month
Posted
Updated 10-Feb-14 2:09am
v2
Comments
JoCodes 10-Feb-14 9:35am    
Whats the issue you are facing?
Hunain Hafeez 10-Feb-14 11:41am    
getting the columns returned from Store procedure and putting them in Razor code, like table etc to display

1 solution

Add the following code in your view.
XML
<table style="width:300px">
<tr>
<td>Employee ID</td>
<td>Month</td>
</tr>
@foreach(GetMonthlyReportResult emp in Mode)
{
    <tr>
<td>@emp.empID</td>
<td>@emp.Month</td> 
</tr>
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900