IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

comment utiliser un composant d'une autre page


Sujet :

ASP.NET

  1. #1
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Mai 2011
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2011
    Messages : 21
    Par défaut comment utiliser un composant d'une autre page
    j'ai une page "WF_chrch_VT.aspx" qui contient une DropDownList, 3 TextBox, une GridView et une button .
    voilà son code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Text;
     
    namespace WebApplication1
    {
        public partial class WF_chrchVT : System.Web.UI.Page
        {
            CrystalReport3 cr3 = new CrystalReport3();
     
            protected void Page_Load(object sender, EventArgs e)
            {
     
            }
     
            protected void DDLccrt_SelectedIndexChanged(object sender, EventArgs e)
            {
                SqlConnection cn = new SqlConnection();
                cn.ConnectionString = "Data Source=amine;Initial Catalog=bdSPR;Integrated Security=True";
                cn.Open();
                SqlCommand com = new SqlCommand("select RibRip,DateVt,MntTotVt from Virement where NumVt='" +DDLccrt.SelectedValue + "'", cn);
                SqlDataReader sdr = com.ExecuteReader();
     
                if (sdr.Read())
                {
     
                    TXTRibRip.Text = sdr[0].ToString();
                    TXTdatevt.Text = sdr[1].ToString();
                    TXTmnttot.Text = sdr[2].ToString();
                    Grd.Visible = true;
     
     
                  }
     
                CrystalDecisions.CrystalReports.Engine.TextObject txt1;
                txt1 = (CrystalDecisions.CrystalReports.Engine.TextObject)cr3.Section2.ReportObjects["Text9"];
                txt1.Text = DDLccrt.Text;
     
            }
     
     
            protected void Button1_Click(object sender, EventArgs e)
            {
                Response.Redirect("CR_imprim.aspx");
            }
        }
    }

    En faite lorsqu'on clique sur Button1 un CrystalReport doit étre affiché, le code source de cette page "CR_imprim.aspx" est le suivant:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Text;
     
    namespace WebApplication1
    {
        public partial class CR_imprim : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                ReportDocument rptDoc = new ReportDocument();
                DS ds = new DS(); // .xsd file name
                DataTable dt = new DataTable();
                // Just set the name of data table
                dt.TableName = "Crystal Report Example";
                dt = VtPc(); //This function is located below this function
                ds.Tables[1].Merge(dt);
                // Your .rpt file path will be below
                rptDoc.Load(Server.MapPath("CrystalReport3.rpt"));
     
                //set dataset to the report viewer.
                rptDoc.SetDataSource(ds);
                CrystalReportViewer1.ReportSource =rptDoc;
     
            }
     
     
     
     
            public DataTable VtPc()
            {
                //Connection string replcae 'databaseservername' with your db server name
                string sqlCon = "Data Source=AMINE;Initial Catalog=bdSPR;Integrated Security=True";
                SqlConnection Con = new SqlConnection(sqlCon);
                SqlCommand cmd = new SqlCommand();
                DataSet ds = null;
                SqlDataAdapter adapter;
                try
                {
                    Con.Open();
                    //Stored procedure calling. It is already in sample db.
                    cmd.CommandText = "VtPc";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection = Con;
                    ds = new DataSet();
                    adapter = new SqlDataAdapter(cmd);
                    adapter.Fill(ds, "PieceComptable");
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    cmd.Dispose();
                    if (Con.State != ConnectionState.Closed)
                        Con.Close();
                }
                return ds.Tables[0];
            }
     
        }
    }

    mais le problème que je peux pas utiliser le composant "cr3" de "WF_chrch_VT.aspx" dans "CR_imprim.aspx" pour afficher
    le TextBox! qu'est ce que je dois faire pour utiliser "cr3" au lieu de "rptDoc" comme ReportSource pour "CR_imprim.aspx"
    Merci d'avance

  2. #2
    Membre très actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Octobre 2006
    Messages
    128
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Enseignement

    Informations forums :
    Inscription : Octobre 2006
    Messages : 128
    Par défaut
    pour faire appel à un formulaire de plusieurs pages, il suffit de créer un usercontrol (controle utilisateur)
    une fois le usercontrol créé, tu l'insere sur toutes les pages aspx que tu veux.

Discussions similaires

  1. Réponses: 2
    Dernier message: 16/08/2009, 13h20
  2. Réponses: 6
    Dernier message: 09/04/2009, 12h36
  3. Comment atteindre les Id d'une autre page?
    Par Jim_Nastiq dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 10/05/2007, 14h54
  4. Réponses: 2
    Dernier message: 28/11/2006, 15h20
  5. Réponses: 3
    Dernier message: 11/05/2006, 17h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo