|
Below is my aspx
<%@ Page Title="Report" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Report.aspx.cs" Inherits="Code" EnableEventValidation="false" %>
<asp:content id="Content1" contentplaceholderid="head" runat="Server">
<asp:label id="Label1" runat="server" font-bold="True" font-size="Medium" font-underline="True"
="" forecolor="#000066" text="Reports">
<asp:gridview id="GridView1" runat="server" showfooter="true" onrowdatabound="GridView1_RowDataBound"
="" width="985px" allowsorting="false" gridlines="None">
<footerstyle horizontalalign="Left" verticalalign="Middle">
<headerstyle font-bold="True" font-names="Times New Roman" font-size="Medium" font-underline="True"
="" forecolor="Blue">
<pagerstyle horizontalalign="Left" verticalalign="Top">
<rowstyle horizontalalign="Left" verticalalign="Middle">
<asp:gridview id="GridView2" runat="server" showfooter="true" allowsorting="false"
="" onrowdatabound="GridView1_RowDataBound" width="985px" gridlines="None" style="margin-left: -315px">
<footerstyle horizontalalign="Left" verticalalign="Middle">
<headerstyle font-bold="True" font-names="Times New Roman" font-size="Medium" font-underline="True"
="" forecolor="Blue">
<pagerstyle horizontalalign="Left" verticalalign="Middle">
<rowstyle horizontalalign="Left" verticalalign="Middle">
I am using the below code to export two gridviews to excel.
protected void ExporttoExcel(object sender, EventArgs e)
{
try
{
GridView[] gvList = null;
gvList = new GridView[] { GridView1, GridView2 };
ExportAv("Report.xls", gvList);
}
catch (Exception ex)
{
}
}
public static void ExportAv(string fileName, GridView[] gvs)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
HttpContext.Current.Response.ContentType = "application/ms-excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
foreach (GridView gv in gvs)
{
gv.AllowPaging = false;
// Create a form to contain the grid
Table table = new Table();
table.GridLines = gv.GridLines;
// add the header row to the table
if (!(gv.Caption == null))
{
TableCell cell = new TableCell();
cell.Text = gv.Caption;
cell.ColumnSpan = 10;
TableRow tr = new TableRow();
tr.Controls.Add(cell);
table.Rows.Add(tr);
}
if (!(gv.HeaderRow == null))
{
table.Rows.Add(gv.HeaderRow);
}
// add each of the data rows to the table
foreach (GridViewRow row in gv.Rows)
{
table.Rows.Add(row);
}
// add the footer row to the table
if (!(gv.FooterRow == null))
{
table.Rows.Add(gv.FooterRow);
}
// render the table into the htmlwriter
table.RenderControl(htw);
}
// render the htmlwriter into the response
string headerTable = @"Report | " + DateTime.Now.ToString("d") + " | ";
HttpContext.Current.Response.Write(headerTable);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}
This code gives a general title called Report and date at the top of the report. Now how can I possibly give a title name for gridviews when exporting the grid to excel?
|
|
|
|
|
I want to Customize WebApi2 Oauth security provider. I want to use my own data base and own DbContext. Please help me how to do?
I am using asp.net 2013.
Thanks
|
|
|
|
|
How do i add a blog on my ASP.NET webpage
|
|
|
|
|
|
Does this download give step-by-step instructions on how to add the codes to a website.
|
|
|
|
|
|
could u till me a free gateway for sending sms from different free sms providers please could any body tell me
|
|
|
|
|
DO NOT repost.
You have already asking this exact question four times in this forum, and received several helpful answers, none of which you have replied to.
Reposting the same question over and over again will only serve to annoy the people who would otherwise be trying to help you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hi MVC4 Razor <a href="/Members/model">@model</a> - what's equivalent in ASPX view engine?
Here's how it's done with Razor - how to do the same in ASPX?
<a href="/Members/model">@model</a> IEnumerable<XYZ.Product>
@{
ViewBag.Title = "Downloads";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div>
<table>
<tr>
<th>Name</th>
<th>Description</th>
<th></th>
</tr>
<a href="/Members/foreach">@foreach</a> (var Package in Model) {
<tr>
<td>
<a href="/Members/html">@Html</a>.DisplayFor(modelItem => Package.Name)
</td>
<td>
<a href="/Members/html">@Html</a>.DisplayFor(modelItem => Package.Description)
</td>
<td>
<a href="/Members/html">@Html</a>.ActionLink("Download", "ProductDownload", Package)
</td>
</tr>
}
</table>
|
|
|
|
|
|
Thankyou Thatraja!
Question, with ASPX you declare your "Model" as such:
<% Inherits="IList<xyz.Product>" %>
Do you still use "Model" keyword when enumerating items from server side script, from "foreach"?
<ul>
<%foreach (var Product in Model)
{ %>
<li><%=Product.Price%></li>
<%} %>
</ul>
|
|
|
|
|
Sorry to disappoint you, I don't use ASPX view as I'm happy with Razor & don't like ASPX view. What happened when you tried that? Always include error message in your message.
Again I'm telling you, go with Razor. It has many advantages, see my previous message.
thatrajaCode converters | Education Needed
No thanks, I am all stocked up. - Luc Pattyn
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
|
|
|
|
|
no worries Thatraja, thanks for your help!
|
|
|
|
|
i have Person table and i want access PersonId in complain table.
DataTable dt = PersonBLL.Select(new Person() { ??????? });
I create select code in BLL.
But what write in place of ????? I don't know.
plz help me...
|
|
|
|
|
Dear All,
I have scenario to encrypt the Password in client side and decrypt it in server side (C# code), this is required for a Online website.
Can any one help me on this task.
- Febin R
-
|
|
|
|
|
For using and saving passwords, you really should not be using encryption, you should really hash your passwords using a salt to be saved in the database. Here[^] is an excellent article that goes through password hashing, and goes into some depth.
Hope it helps
Everyone dies - but not everyone lives
|
|
|
|
|
Just use SSL[^]; that way, the whole request and response will be encrypted for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hello, I'm basically following steps as described here[^], building a new MVC4 app with my custom MembershipProvider extending from "WebMatrix.WebData.SimpleMembershipProvider".
Question is, what if I don't want to persists my users in database at all? With SimpleMembershipProvider, you must call "WebSecurity.InitializeDatabaseConnection" from "InitializeSimpleMembershipAttribute \ LazyInitializer.EnsureInitialized" at least once during startup.
Thank you!
|
|
|
|
|
I am reading a file into datatable.
In file I have 3 column but in my datatable 4.
Column 4 in datatable needs to be populated at run time before or after full file is loaded into dt.
how do I do this?
Dim lines = File.ReadAllLines(FileName)
For Each line As String In lines
dt.Rows.Add(line.Split("|"))
Next
|
|
|
|
|
What file you are trying to read from..??
|
|
|
|
|
could you share the information about exceptions.
Exp: in one class i am using more then on exception and also null bull exception.
|
|
|
|
|
One google[^] search will give you lots of results for your query..
|
|
|
|
|
Your question is not clear. Can you be more specific?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
is it possible to create a small application (asp.net) for the managers in the company to search for desired extension and call the extension directly from the application using his/her extension .
thanks in advance
|
|
|
|
|
You can refer this and proceed according to your requirement
Phone Book in C#[^]
else go through google[^]
Hope it will help..
|
|
|
|