TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
2.1k
472.8k
Extraction list to filter different records from db in asp.net mvc
Apr 17 2021 8:28 AM
Hi Team
I have a button, but i want to know how can i extract the list of records from the button itself when clicked
public
IList < ScheduleManModel > GetScheduleManList()
{
DbAccessContext db =
new
DbAccessContext();
var scheduleList = (from e
in
db.ScheduleMan join d
in
db.ScheduleTbl on e.ScheduleId equals d.YearTblId select
new
ScheduleManModel {
Year = e.Year,
Week = e.Week,
250 Buck = (
int
) e.250 Buck,
RACS = e.RACS,
YBR250 = d.YBR250
}).ToList();
return
scheduleList;
}
public
ActionResult ExtractionToExcel() {
var gv =
new
GridView();
gv.DataSource =
this
.ScheduleManList();
gv.DataBind();
Response.ClearContent();
Response.Buffer =
true
;
Response.AddHeader(
"content-disposition"
,
"attachment; filename=DemoExcel.xls"
);
Response.ContentType =
"application/ms-excel"
;
Response.Charset =
""
;
StringWriter objStringWriter =
new
StringWriter();
HtmlTextWriter objHtmlTextWriter =
new
HtmlTextWriter(objStringWriter);
gv.RenderControl(objHtmlTextWriter);
Response.Output.Write(objStringWriter.ToString());
Response.Flush();
Response.End();
return
View(
"Index"
);
}
}
}
@using (Html.BeginForm(
"ExportToExcel"
,
"Schedule"
, FormMethod.Post))
{
<br />
<br />
<h2>
Extraction Button
</h2>
<table style=
"background-color: white; width: 100%;"
>
<tr>
<th style=
"border: 1px solid black; text-align: left; width: 20%; padding-left: 20px;"
>
Year
</th>
<th style=
"border: 2px solid black; text-align: center; width: 20%"
>
Week
</th>
<th style=
"border: 2px solid black; text-align: center; width: 20%"
>
RACS
</th>
<th style=
"border: 2px solid black; text-align: center; width: 20%"
>
270 Buck
</th>
<th style=
"border: 2px solid black; text-align: center; width: 20%"
>
250 Buck
</th>
</tr>
@foreach (
var
itm
in
Model)
{
<tr>
<td colspan=
"4"
>
<br />
<br />
<input type=
"submit"
value=
"Extraction"
class
=
"button"
/>
</td>
</tr>
</table>
Using asp.net mvc to export them as excel, has anyone ever worked on that before?
Reply
Answers (
2
)
Problem in regex validation to match Arabic with English text
Insert data into multiple table in asp.net c sharp using click button