通常の.aspxでは、gridviewからデータをエクスポートしようとしていますが、webusercontrl.ascxフォームでこれを試してみると、次のようなエラーが表示されますVerifyRenderingInServerForm(System.Web.UI.Control)グリッドビューをPDFにエクスポート中
VerifyRenderingInServerForm(System.Web.UI.Control)': no suitable method found to override....
どのように私はwebusercontrol.ascxでデータをエクスポートすることができ、私を助けてください... ここでは私のコードである
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
namespace MortgageSaver
{
public partial class Paymentreportsviewcontrl : System.Web.UI.UserControl
{
MortgagesaverEntities mortgageentity = new MortgagesaverEntities();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Session["Username"] != null)
{
if (Session["Loanid"] != null)
{
txtloanid.Text = Session["Loanid"].ToString();
grdviewPayments.Attributes.Add("bordercolor ", "#A4C2CE");
GetPaymentReport();
}
}
else
{
Response.Redirect("AdminLogin.aspx");
}
}
}
private void GetPaymentReport()
{
try
{
string todate = txttodate.Text;
string[] todatesplt = todate.Split('-');
int todatemnth = Convert.ToInt32(todatesplt[0]);
int todatedate = Convert.ToInt32(todatesplt[1]);
int todateyr = Convert.ToInt32(todatesplt[2]);
string fromdate = txtfromdate.Text;
string[] frmdatesplt = fromdate.Split('-');
int frmdatemnth = Convert.ToInt32(frmdatesplt[0]);
int frmdatedate = Convert.ToInt32(frmdatesplt[1]);
int frmdateyr = Convert.ToInt32(frmdatesplt[2]);
DateTime start = new DateTime(frmdateyr, frmdatemnth, frmdatedate);
DateTime end = new DateTime(todateyr, todatemnth, todatedate);
int loanpaymentid = Convert.ToInt32(Session["Loanid"].ToString());
var query = from p in mortgageentity.Payments
join D in mortgageentity.Debit_Method on p.Debit_Method_ID equals D.Debit_Method_ID
join pt in mortgageentity.Payment_Type on p.Payment_Type_ID equals pt.Payment_Type_ID
where (p.Client_Pmt_Date >= start) && (p.Client_Pmt_Date <= end) && (p.Loan_ID == loanpaymentid)orderby p.Client_Pmt_Date descending
select new
{
p.Pmt_ID,
p.Loan_ID,
p.Client_Pmt_Date,
p.MtgSvr_Pmt_Start_Date2,
D.Debit_Method_Desc,
p.Total_Debit_Amt,
p.CreditAmt,
p.LenderAmt,
pt.Payment_Type_Desc,
p.Return_Code,
p.Returned_Date
};
grdviewPayments.DataSource = query.ToList();
grdviewPayments.DataBind();
}
catch { }
}
protected string Getammount(object MonthPayAmt)
{
if (MonthPayAmt != "")
{
return "$" + MonthPayAmt;
}
else
return null;
}
protected void btnviewreport_Click(object sender, EventArgs e)
{
grdviewPayments.Attributes.Add("bordercolor ", "#A4C2CE");
GetPaymentReport();
}
public override void VerifyRenderingInServerForm(grdviewPayments)
{
/* Verifies that the control is rendered */
}
protected void btnemail_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
grdviewPayments.AllowPaging = true;
grdviewPayments.DataBind();
grdviewPayments.RenderControl(hw);
grdviewPayments.HeaderRow.Style.Add("width", "15%");
grdviewPayments.HeaderRow.Style.Add("font-size", "10px");
grdviewPayments.Style.Add("text-decoration", "none");
grdviewPayments.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
grdviewPayments.Style.Add("font-size", "8px");
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
}
}
はい私はページ内のSystem.Web.UIを使用してこの名前空間を使用し、public override void VerifyRenderingInServerForm(コントロールコントロール)を宣言しますが、VerifyRenderingInServerFormを受け入れることはできません。 – Victor
VerifyRenderingInServerForm(System.Web.UI.Control ) ': – Victor
はあなたが試すことができ上書きすることが分かっていない適切な方法_publicオーバーライド無効VerifyRenderingInServerForm(YourGridview) {} _ –