locked
Call method from one webform to another webform RRS feed

  • Question

  • User639567535 posted

    how to Call method from one webform to another webform

    Thursday, August 11, 2016 11:04 AM

All replies

  • User-1952463932 posted

    It depends, however the simplest thing to do is to use a static method.

    Friday, August 12, 2016 6:26 AM
  • User61956409 posted

    Hi Bakhtawar Ashiq,

    how to Call method from one webform to another webform

    Firstly, please explain more about the issue you are facing now.

    Secondly, you could refer to the following threads that discussed about “call a method from another web page”.

    http://forums.asp.net/t/1776508.aspx

    http://stackoverflow.com/questions/20992828/how-to-call-function-from-one-page-to-another-page-in-asp-net-using-c-sharp

    Best Regards,

    Fei Han

    Friday, August 12, 2016 7:29 AM
  • User639567535 posted

    I try this code for crystal report but data is not display in crystal report only header region and owner name is display ..

    First i create dataset

    dataset

    then i add this in crystal report

    report

    then i create report_class class

     public void Bindreport_class(Report_Detail report, DateTime fromdate, DateTime todate, string region)
        {
            TrackDataEntities1 t = new TrackDataEntities1();
            DateTime fdate = new DateTime(fromdate.Year, fromdate.Month, fromdate.Day, 0, 0, 0);
            DateTime tdate = new DateTime(todate.Year, todate.Month, todate.Day, 23, 59, 59);
            List<griddataresult_Result> gr = t.griddataresult(fdate, tdate, region).ToList();
            DataTable dt = new DataTable();
    
            dt.Columns.Add("OwnerName", typeof(string));
            dt.Columns.Add("Region", typeof(string));
    
            foreach (var d in gr)
            {
                dt.Rows.Add(d.OwnerName,d.Region);
            }
    
            report.SetDataSource(dt);
    
    
        }

    Then i create Reports form where i drag crystal report viewer

    protected void Page_Load(object sender, EventArgs e)
        {
    
            Report_Detail report = new Report_Detail();
            CrystalReportViewer1.ReportSource = report;
            CrystalReportViewer1.DataBind();
        }

    Then i create another form where i drag button .. When i click on this button then Reports form is open in new tab and report will be display

    Report_Detail is crystal report name

     protected void Button5_Click(object sender, EventArgs e)
        {
            report_class r = new report_class();
            Report_Detail report = new Report_Detail();
            r.Bindreport_class(report, Convert.ToDateTime(fromdate.Value), Convert.ToDateTime(todate.Value), regiondrop.SelectedValue);
            Response.Redirect("Reports.aspx");
        }

    but data is not display

    no data

    any solution?

    Monday, August 15, 2016 7:47 AM
  • User61956409 posted

    Hi Bakhtawar Ashiq,

    List<griddataresult_Result> gr = t.griddataresult(fdate, tdate, region).ToList();

    It seems that you call griddataresult() that could return a list, please debug your code to make sure if the code are executed as you expect.

    dt.Rows.Add(d.OwnerName,d.Region);

    And please make sure if you fill data rows to datatable object dt.

    Best Regards,

    Fei Han

    Wednesday, August 31, 2016 6:22 AM