locked
crystal report Print, Export not working. RRS feed

  • Question

  • User821936469 posted

    hey guyz,

                 I am having an report Application where i generate reports with the help of crystal report viewer.

    I am able to display the report data through the Mysql database using store procdure.

    Am finding it difficult to use the print and export function in it.

    after the report gets displayed at the Search button click after my filteration process and later if i click on the export button it gives me an exception saying

                     exception `   ~ Report Source not available.

    When I click the export button, the page is postback, and the CrystalReportViewer disappeared, and I god my old web page (without CrystalReportViewer) containing the following message:

                    "Failed to export using the options you specified. Please check your options and try again."

    I dont want the crystal report to get displayed at the load event but i want it after some filteration and later on the click of Search Button.

    Following is my Search Button click code through which i get the report on the Crystal Report Viewer.

    Mention me if i need to change some properties of  Crystal Report Viewer which will help me to get rid of it.

    public void btn_Search_Click(object sender, EventArgs e)
          {
    
    
            string sd = Request.Form["txtStartDate"];
    
            string ed = Request.Form["txtEndDate"];
    
            DataSet myData = new DataSet();
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlDataAdapter da = new MySqlDataAdapter("iris_rep_db.SP_ENC_Rep", con);
    
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
    
            da.SelectCommand.Parameters.AddWithValue("param_start_dte", sd);
            
            da.SelectCommand.Parameters.AddWithValue("param_end_dte", ed);
            
            da.SelectCommand.Parameters.AddWithValue("param_reg", ddl_region.SelectedValue);
            
            da.SelectCommand.Parameters.AddWithValue("param_ct", ddl_center_type.SelectedValue);
            
            da.SelectCommand.Parameters.AddWithValue("param_center", ddl_center.SelectedValue);
            
            ReportDocument myReport = new ReportDocument();
    
            da.Fill(myData);
    
            myReport.Load(Server.MapPath("~/Application Layer/Reports/ENC/ENC.rpt"));
    
            myReport.SetParameterValue("param_start_dte", sd);
    
            myReport.SetParameterValue("param_end_dte", ed);
            
            myReport.SetParameterValue("param_reg",ddl_region.SelectedValue);
    
            myReport.SetParameterValue ("param_ct", ddl_center_type.SelectedValue);
            
            myReport.SetParameterValue("param_center", ddl_center.SelectedValue);
            
            //myReport.SetDataSource(myData);
           
            ENCReport.ReportSource = myReport;
        }
    

    Thanks in advance,

    Regards,

    Sushant Maragaje.

    Saturday, November 29, 2014 2:32 AM

Answers

  • User61956409 posted

    Hi Sushant,

    Thanks for your post.

    I dont want the crystal report to get displayed at the load event but i want it after some filteration and later on the click of Search Button.

    As for your problem, this article will help to resolve it. Instead of binding the Crystal Report directly in Page Load, author created a method so that it can be used for binding report when page loads as well as when the export button is clicked. You could refer to it and modify your code to meet your requirements.

    Hope it will be helpful to you.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 1, 2014 8:40 PM
  • User812858302 posted

    Add this code in ur button search click

    ENCReport.ReportSource = myReport;
    
    Session.Add("Report", myReport);

    and call session in ur page load like this

     ENCReport.ReportSource = Session["Report"];

    Hope it solve your crystal Report Issue

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 5, 2014 12:34 AM
  • User821936469 posted

    hey guyz i tried out with the following code and it worked for me.

    hope it help yourl.

    Thanks sushant2014

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using MySql.Data.MySqlClient;
    using System.Configuration;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using CrystalDecisions.Web;
    using CrystalDecisions.ReportSource;
    
    public partial class Application_Layer_Reports_ENC_ENC_Report : System.Web.UI.Page
    {
        ReportDocument myReport = new ReportDocument();
    
        protected void Page_Load(object sender, EventArgs e)
        {
    
            ENCReport.ReportSource = Session["Report"];
    
            if (!IsPostBack)
            {
    
                ddl_filter_crct();
    
                ddl_center_type.Items.Insert(0, new ListItem("Select Type", "0"));
    
                ddl_center.Items.Insert(0, new ListItem("Select Center", "0"));
    
                ddl_region.Items.Insert(0, new ListItem("Select Region", "0"));
    
                string sd = Request.Form["txtStartDate"];
    
                string ed = Request.Form["txtEndDate"];
    
                //ddl_filter_region();
    
                //ddl_filter_center();
            }
    
        }
    
    
    
        public void ddl_filter_crct()
        {
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlCommand cmd = new MySqlCommand("iris_rep_db.SP_CRCT_Search", con);
    
            cmd.CommandType = CommandType.StoredProcedure;
    
            DataSet ds = new DataSet();
    
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);
    
            da.Fill(ds);
    
            ddl_center_type.DataSource = ds.Tables[0];
    
            ddl_center_type.DataValueField = "num_id";
    
            ddl_center_type.DataTextField = "str_data";
    
            ddl_center_type.DataBind();
    
            ddl_region.DataSource = ds.Tables[1];
    
            ddl_region.DataValueField = "num_region_id";
    
            ddl_region.DataTextField = "str_region_name";
    
            ddl_region.DataBind();
    
            ddl_center.DataSource = ds.Tables[2];
    
            ddl_center.DataValueField = "id";
    
            ddl_center.DataTextField = "name";
    
            ddl_center.DataBind();
    
        }
    
        public void btn_Search_Click(object sender, EventArgs e)
        {
    
            try
       
            {
                ENCReport.Visible = true;
    
                string sd = Request.Form["txtStartDate"];
    
                string ed = Request.Form["txtEndDate"];
    
                MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
                con.Open();
    
                myReport.Load(Server.MapPath("~/Application Layer/Reports/ENC/ENC.rpt"));
    
                myReport.SetParameterValue("param_start_dte", sd);
    
                myReport.SetParameterValue("param_end_dte", ed);
    
                myReport.SetParameterValue("param_reg", ddl_region.SelectedValue);
    
                myReport.SetParameterValue("param_ct", ddl_center_type.SelectedValue);
    
                myReport.SetParameterValue("param_center", ddl_center.SelectedValue);
    
                //ExportOptions exportOpts = new ExportOptions();
    
                //ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions();
    
                //exportOpts = myReport.ExportOptions;
    
                //// Set the excel format options.
    
                //excelFormatOpts.ExcelUseConstantColumnWidth = true;
                
                //exportOpts.ExportFormatType = ExportFormatType.Excel;
                
                //exportOpts.FormatOptions = excelFormatOpts;
    
    
                //myReport.Export();
    
                ENCReport.ReportSource = myReport;
    
                Session.Add("Report", myReport);
            }
            catch
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "validation",
    
                  "<script language='javascript'>alert('Please Select Start Date & End Date')</script>");
    
            }
        }
    
    
        protected void ddl_center_type_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddl_region.Items.Clear();
    
            ddl_center.Items.Clear();
    
            ddl_center.Enabled = false;
    
            ddl_center.Items.Insert(0, new ListItem("Select Center", "0"));
    
            ddl_region.Items.Insert(0, new ListItem("Select Region", "0"));
    
            ddl_region.AppendDataBoundItems = true;
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlCommand cmd = new MySqlCommand("iris_rep_db.SP_CRCT_Cas1", con);
    
            cmd.Parameters.AddWithValue("param_ct", ddl_center_type.SelectedItem.Value);
    
            cmd.CommandType = CommandType.StoredProcedure;
    
            cmd.Connection = con;
    
            try
            {
    
                ddl_region.DataSource = cmd.ExecuteReader();
    
                ddl_region.DataTextField = "region";
    
                ddl_region.DataValueField = "rid";
    
                ddl_region.DataBind();
    
                if (ddl_region.Items.Count > 1)
                {
                    ddl_region.Enabled = true;
    
                }
    
                else
                {
                    //ddl_manager.Enabled = false;
                }
    
    
            }
    
            catch (Exception ex)
            {
                throw ex;
    
            }
    
        }
    
        protected void ddl_region_SelectedIndexChanged(object sender, EventArgs e)
        {
    
            ddl_center.Items.Clear();
    
            ddl_center.Enabled = true;
    
            ddl_center.Items.Insert(0, new ListItem("Select Center", "0"));
    
            ddl_center.AppendDataBoundItems = true;
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlCommand cmd = new MySqlCommand("iris_rep_db.SP_CRCT_Cas2", con);
    
            cmd.Parameters.AddWithValue("param_reg", ddl_region.SelectedItem.Value);
    
            cmd.Parameters.AddWithValue("param_ct", ddl_center_type.SelectedValue);
    
            cmd.CommandType = CommandType.StoredProcedure;
    
            cmd.Connection = con;
    
            try
            {
    
                ddl_center.DataSource = cmd.ExecuteReader();
    
                ddl_center.DataTextField = "center";
    
                ddl_center.DataValueField = "cid";
    
                ddl_center.DataBind();
    
                if (ddl_center.Items.Count > 1)
                {
                    ddl_center.Enabled = true;
                }
    
                else
                {
    
                }
    
            }
    
            catch (Exception ex)
            {
                throw ex;
    
            }
    
    
        }
    
    
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 5, 2014 12:39 AM

All replies

  • User61956409 posted

    Hi Sushant,

    Thanks for your post.

    I dont want the crystal report to get displayed at the load event but i want it after some filteration and later on the click of Search Button.

    As for your problem, this article will help to resolve it. Instead of binding the Crystal Report directly in Page Load, author created a method so that it can be used for binding report when page loads as well as when the export button is clicked. You could refer to it and modify your code to meet your requirements.

    Hope it will be helpful to you.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 1, 2014 8:40 PM
  • User821936469 posted

    hey Fei Han,

                      I am finding it difficult to alter my code with the link code which you have provided.

                     I am providing you my complete code of that report form.

                    Please provide the changes to be done in that code.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using MySql.Data.MySqlClient;
    using System.Configuration;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using CrystalDecisions.Web;
    using CrystalDecisions.ReportSource;
    
    public partial class Application_Layer_Reports_ENC_ENC_Report : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Panel2.Visible = false;
    
    
            if (!IsPostBack)
            {
                ddl_filter_crct();
    
                ddl_center_type.Items.Insert(0, new ListItem("Select Type", "0"));
    
                ddl_center.Items.Insert(0, new ListItem("Select Center", "0"));
    
                ddl_region.Items.Insert(0, new ListItem("Select Region", "0"));
    
                string sd = Request.Form["txtStartDate"];
    
                string ed = Request.Form["txtEndDate"];
    
                     
                //ddl_filter_region();
    
                //ddl_filter_center();
            }
    
        }
    
    
    
        public void ddl_filter_crct()
        {
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlCommand cmd = new MySqlCommand("iris_rep_db.SP_CRCT_Search", con);
    
            cmd.CommandType = CommandType.StoredProcedure;
    
            DataSet ds = new DataSet();
    
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);
    
            da.Fill(ds);
    
            ddl_center_type.DataSource = ds.Tables[0];
    
            ddl_center_type.DataValueField = "num_id";
    
            ddl_center_type.DataTextField = "str_data";
    
            ddl_center_type.DataBind();
    
            ddl_region.DataSource = ds.Tables[1];
    
            ddl_region.DataValueField = "num_region_id";
    
            ddl_region.DataTextField = "str_region_name";
    
            ddl_region.DataBind();
    
            ddl_center.DataSource = ds.Tables[2];
    
            ddl_center.DataValueField = "id";
    
            ddl_center.DataTextField = "name";
    
            ddl_center.DataBind();
    
        }
    
             public void btn_Search_Click(object sender, EventArgs e)
          {
    
              Panel2.Visible = true;
    
            string sd = Request.Form["txtStartDate"];
    
            string ed = Request.Form["txtEndDate"];
    
            DataSet myData = new DataSet();
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlDataAdapter da = new MySqlDataAdapter("iris_rep_db.SP_ENC_Rep", con);
    
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
    
            da.SelectCommand.Parameters.AddWithValue("param_start_dte", sd);
            
            da.SelectCommand.Parameters.AddWithValue("param_end_dte", ed);
            
            da.SelectCommand.Parameters.AddWithValue("param_reg", ddl_region.SelectedValue);
            
            da.SelectCommand.Parameters.AddWithValue("param_ct", ddl_center_type.SelectedValue);
            
            da.SelectCommand.Parameters.AddWithValue("param_center", ddl_center.SelectedValue);
            
            ReportDocument myReport = new ReportDocument();
    
            da.Fill(myData);
    
            myReport.Load(Server.MapPath("~/Application Layer/Reports/ENC/ENC.rpt"));
    
            myReport.SetParameterValue("param_start_dte", sd);
    
            myReport.SetParameterValue("param_end_dte", ed);
            
            myReport.SetParameterValue("param_reg",ddl_region.SelectedValue);
    
            myReport.SetParameterValue ("param_ct", ddl_center_type.SelectedValue);
            
            myReport.SetParameterValue("param_center", ddl_center.SelectedValue);
            
            //myReport.SetDataSource(myData);
           
            ENCReport.ReportSource = myReport;
        }
    
    
        protected void ddl_center_type_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddl_region.Items.Clear();
    
            ddl_center.Items.Clear();
    
            ddl_center.Enabled = false;
    
            ddl_center.Items.Insert(0, new ListItem("Select Center", "0"));
    
            ddl_region.Items.Insert(0, new ListItem("Select Region", "0")); 
    
            ddl_region.AppendDataBoundItems = true;
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlCommand cmd = new MySqlCommand("iris_rep_db.SP_CRCT_Cas1", con);
    
            cmd.Parameters.AddWithValue("param_ct", ddl_center_type.SelectedItem.Value);
    
            cmd.CommandType = CommandType.StoredProcedure;
    
            cmd.Connection = con;
    
            try
            
            {
    
                ddl_region.DataSource = cmd.ExecuteReader();
    
                ddl_region.DataTextField = "region";
    
                ddl_region.DataValueField = "rid";
    
                ddl_region.DataBind();
    
                if (ddl_region.Items.Count > 1)
                
                {
                    ddl_region.Enabled = true;
    
                }
    
                else
               
                {
                    //ddl_manager.Enabled = false;
                }
    
    
            }
    
            catch (Exception ex)
            
            {
                throw ex;
    
            }
    
        }
    
        protected void ddl_region_SelectedIndexChanged(object sender, EventArgs e)
        
        {
    
            ddl_center.Items.Clear();
    
            ddl_center.Enabled = true;
    
            ddl_center.Items.Insert(0, new ListItem("Select Center", "0"));
    
            ddl_center.AppendDataBoundItems = true;
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlCommand cmd = new MySqlCommand("iris_rep_db.SP_CRCT_Cas2", con);
    
            cmd.Parameters.AddWithValue("param_reg", ddl_region.SelectedItem.Value);
    
            cmd.Parameters.AddWithValue("param_ct", ddl_center_type.SelectedValue);
    
            cmd.CommandType = CommandType.StoredProcedure;
    
            cmd.Connection = con;
    
            try
            {
    
                ddl_center.DataSource = cmd.ExecuteReader();
    
                ddl_center.DataTextField = "center";
    
                ddl_center.DataValueField = "cid";
    
                ddl_center.DataBind();
    
                if (ddl_center.Items.Count > 1)
                {
                    ddl_center.Enabled = true;
                }
    
                else
                {
    
                }
    
            }
    
            catch (Exception ex)
            {
                throw ex;
    
            }
    
    
        }
    
    }

    Thanks

    Sushant2014

    Tuesday, December 2, 2014 3:40 AM
  • User503812343 posted

    you can write the code in button click event of btnSearch event. 

    see below article which gives you step by step implementation 

    display crystal report on button click in asp.net

    Tuesday, December 2, 2014 9:11 AM
  • User812858302 posted

    Add this code in ur button search click

    ENCReport.ReportSource = myReport;
    
    Session.Add("Report", myReport);

    and call session in ur page load like this

     ENCReport.ReportSource = Session["Report"];

    Hope it solve your crystal Report Issue

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 5, 2014 12:34 AM
  • User821936469 posted

    hey guyz i tried out with the following code and it worked for me.

    hope it help yourl.

    Thanks sushant2014

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using MySql.Data.MySqlClient;
    using System.Configuration;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using CrystalDecisions.Web;
    using CrystalDecisions.ReportSource;
    
    public partial class Application_Layer_Reports_ENC_ENC_Report : System.Web.UI.Page
    {
        ReportDocument myReport = new ReportDocument();
    
        protected void Page_Load(object sender, EventArgs e)
        {
    
            ENCReport.ReportSource = Session["Report"];
    
            if (!IsPostBack)
            {
    
                ddl_filter_crct();
    
                ddl_center_type.Items.Insert(0, new ListItem("Select Type", "0"));
    
                ddl_center.Items.Insert(0, new ListItem("Select Center", "0"));
    
                ddl_region.Items.Insert(0, new ListItem("Select Region", "0"));
    
                string sd = Request.Form["txtStartDate"];
    
                string ed = Request.Form["txtEndDate"];
    
                //ddl_filter_region();
    
                //ddl_filter_center();
            }
    
        }
    
    
    
        public void ddl_filter_crct()
        {
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlCommand cmd = new MySqlCommand("iris_rep_db.SP_CRCT_Search", con);
    
            cmd.CommandType = CommandType.StoredProcedure;
    
            DataSet ds = new DataSet();
    
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);
    
            da.Fill(ds);
    
            ddl_center_type.DataSource = ds.Tables[0];
    
            ddl_center_type.DataValueField = "num_id";
    
            ddl_center_type.DataTextField = "str_data";
    
            ddl_center_type.DataBind();
    
            ddl_region.DataSource = ds.Tables[1];
    
            ddl_region.DataValueField = "num_region_id";
    
            ddl_region.DataTextField = "str_region_name";
    
            ddl_region.DataBind();
    
            ddl_center.DataSource = ds.Tables[2];
    
            ddl_center.DataValueField = "id";
    
            ddl_center.DataTextField = "name";
    
            ddl_center.DataBind();
    
        }
    
        public void btn_Search_Click(object sender, EventArgs e)
        {
    
            try
       
            {
                ENCReport.Visible = true;
    
                string sd = Request.Form["txtStartDate"];
    
                string ed = Request.Form["txtEndDate"];
    
                MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
                con.Open();
    
                myReport.Load(Server.MapPath("~/Application Layer/Reports/ENC/ENC.rpt"));
    
                myReport.SetParameterValue("param_start_dte", sd);
    
                myReport.SetParameterValue("param_end_dte", ed);
    
                myReport.SetParameterValue("param_reg", ddl_region.SelectedValue);
    
                myReport.SetParameterValue("param_ct", ddl_center_type.SelectedValue);
    
                myReport.SetParameterValue("param_center", ddl_center.SelectedValue);
    
                //ExportOptions exportOpts = new ExportOptions();
    
                //ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions();
    
                //exportOpts = myReport.ExportOptions;
    
                //// Set the excel format options.
    
                //excelFormatOpts.ExcelUseConstantColumnWidth = true;
                
                //exportOpts.ExportFormatType = ExportFormatType.Excel;
                
                //exportOpts.FormatOptions = excelFormatOpts;
    
    
                //myReport.Export();
    
                ENCReport.ReportSource = myReport;
    
                Session.Add("Report", myReport);
            }
            catch
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "validation",
    
                  "<script language='javascript'>alert('Please Select Start Date & End Date')</script>");
    
            }
        }
    
    
        protected void ddl_center_type_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddl_region.Items.Clear();
    
            ddl_center.Items.Clear();
    
            ddl_center.Enabled = false;
    
            ddl_center.Items.Insert(0, new ListItem("Select Center", "0"));
    
            ddl_region.Items.Insert(0, new ListItem("Select Region", "0"));
    
            ddl_region.AppendDataBoundItems = true;
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlCommand cmd = new MySqlCommand("iris_rep_db.SP_CRCT_Cas1", con);
    
            cmd.Parameters.AddWithValue("param_ct", ddl_center_type.SelectedItem.Value);
    
            cmd.CommandType = CommandType.StoredProcedure;
    
            cmd.Connection = con;
    
            try
            {
    
                ddl_region.DataSource = cmd.ExecuteReader();
    
                ddl_region.DataTextField = "region";
    
                ddl_region.DataValueField = "rid";
    
                ddl_region.DataBind();
    
                if (ddl_region.Items.Count > 1)
                {
                    ddl_region.Enabled = true;
    
                }
    
                else
                {
                    //ddl_manager.Enabled = false;
                }
    
    
            }
    
            catch (Exception ex)
            {
                throw ex;
    
            }
    
        }
    
        protected void ddl_region_SelectedIndexChanged(object sender, EventArgs e)
        {
    
            ddl_center.Items.Clear();
    
            ddl_center.Enabled = true;
    
            ddl_center.Items.Insert(0, new ListItem("Select Center", "0"));
    
            ddl_center.AppendDataBoundItems = true;
    
            MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["iris_rep_dbConnectionString"].ConnectionString);
    
            con.Open();
    
            MySqlCommand cmd = new MySqlCommand("iris_rep_db.SP_CRCT_Cas2", con);
    
            cmd.Parameters.AddWithValue("param_reg", ddl_region.SelectedItem.Value);
    
            cmd.Parameters.AddWithValue("param_ct", ddl_center_type.SelectedValue);
    
            cmd.CommandType = CommandType.StoredProcedure;
    
            cmd.Connection = con;
    
            try
            {
    
                ddl_center.DataSource = cmd.ExecuteReader();
    
                ddl_center.DataTextField = "center";
    
                ddl_center.DataValueField = "cid";
    
                ddl_center.DataBind();
    
                if (ddl_center.Items.Count > 1)
                {
                    ddl_center.Enabled = true;
                }
    
                else
                {
    
                }
    
            }
    
            catch (Exception ex)
            {
                throw ex;
    
            }
    
    
        }
    
    
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 5, 2014 12:39 AM