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 :

Problème GridView basé


Sujet :

ASP.NET

  1. #1
    Nouveau candidat au Club
    Inscrit en
    Août 2011
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Août 2011
    Messages : 2
    Par défaut Problème GridView basé
    Bonjour,

    J'essai d'alimenter un gridview à partir d'une requete Oracle.

    Je rencontre actuellement le message :
    Le nom 'GRIDVIEW_CHOIX_APPS' n'existe pas dans le contexte actuel
    Auriez vous une idée pour me dépanner ?

    Merdi d'avance

    Ci dessous le code :
    ASPX
    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
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
     
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="PageDynApp.aspx.cs" Inherits="_Default" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
            #Table7
            {
                width: 442px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="divResult"></div>
    <div runat="server">
        <asp:Panel runat="server" CssClass="PanelInfo">
            <table id="Table7" class="Info">
                <tr class="ListRow">
                <td class="CellValue"><span class="Label">
                    <asp:GridView ID="GRIDVIEW_CHOIX_APPS" runat="server" 
                        AutoGenerateColumns="False" CssClass="GridView" ToolTip="Applications"  
                        ShowFooter="False" Width="425px">
                        <Columns>
     
                            <asp:TemplateField HeaderText="Applications">
                                <EditItemTemplate>
                                    <asp:Label ID="GRIDVIEW_CHOIX_APPS_APP" runat="server" Width="400px"></asp:Label>
                                </EditItemTemplate>
                                <ItemTemplate>
                                <asp:Label ID="GRIDVIEW_CHOIX_APPS_APP" runat="server" ></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="Label" HorizontalAlign="Center" />
                                <FooterStyle HorizontalAlign="Right" />
                                <ItemStyle HorizontalAlign="Right" Width="65px" />
                                <ControlStyle CssClass="Value" />
                            </asp:TemplateField>
                        </Columns>
                        <HeaderStyle CssClass="Header" />
                        <RowStyle CssClass="Row" />
                        <AlternatingRowStyle CssClass="AlternatingRow" />
                    </asp:GridView>
                   </span>
                </td>
                </tr>
     
                </table>
     
            </asp:Panel>
            <br />
        </div>
     
     
     
     
     
     
     
     
     
     
        <!--
        &nbsp;<span ><asp:Button ID="ButtonOK" runat="server" Text="OK" Height="21px" 
            Width="31px"/>
            <br />
            <asp:TextBox ID="TEXTBOX_UTIL" runat="server" Visible="False"></asp:TextBox>
             <asp:TextBox ID="TEXTBOX1" runat="server" Visible="False"></asp:TextBox>
              <asp:TextBox ID="TEXTBOX2" runat="server" Visible="False"></asp:TextBox>
            </span>
        -->
       <!-- HIDDEN FIELDS AND DATA SOURCES -->
        <asp:Panel ID="HiddenFields" runat="server">
            <asp:SqlDataSource ID="SqlDataApp" runat="server" 
                ConnectionString="<%$ ConnectionStrings:MyDataBase %>" 
                ProviderName="<%$ ConnectionStrings:MyDataBase.ProviderName %>" 
                SelectCommand="SELECT ' ' as NUM_ECRAN, ' ' as LIB FROM DUAL UNION select TO_CHAR(c.id_combo_value) as NUM_ECRAN, des_oa as LIB from objetapp_usr, objetapp, oa_carac, csd_profile_templ_ticket_type c, password p where objetapp_usr.code_oa = objetapp.code_oa and oa_carac.code_oa = objetapp_usr.code_oa and objetapp_usr.code_usr = p.code_usr and p.csdp_code = c.id_profile and val_car1 = id_temp_form and code_cw = '0000000005' and objetapp_usr.code_usr = :code_util">
                <SelectParameters>
                    <asp:ControlParameter Name="code_util" ControlID="TEXTBOX_UTIL" PropertyName="Text"/>
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataPopGridApps" runat="server" 
                ConnectionString="<%$ ConnectionStrings:MyDataBase %>"
                ProviderName="<%$ ConnectionStrings:MyDataBase.ProviderName %>">
            </asp:SqlDataSource>
     
        </asp:Panel>
        </form>
    </body>
    </html>
    C#
    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
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
     
    using System;
    using System.Data;
    using System.IO;
    using System.Configuration;
    using System.Globalization;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.Sql;
    using System.Data.SqlClient;
    using Oracle.DataAccess.Client;
    using System.Data.Common;
     
    public partial class _Default : System.Web.UI.Page 
    {
        //String appc_code;
        String url;
        String window_open;
        String usercode;
        String login;
        String password;
     
        //String string_connexion = "Data Source=AGILP;User Id=PSSOFT;Password=PSSAGILP1020;";
     
        protected void Page_Load(object sender, EventArgs e)
        {
            usercode = Request.Params["code_usr"];
            login = Request.Params["login"];
            password = Request.Params["password"];
     
            TEXTBOX_UTIL.Text = usercode;
     
            //appc_code = this.VISA_CHOIX_APP.SelectedValue;
     
            /*String selreq1 = "select TO_CHAR(c.id_combo_value) as NUM_ECRAN, des_oa as LIB ";
            String fromsel1 = "from objetapp_usr, objetapp, oa_carac, csd_profile_templ_ticket_type c, password p ";
            String wheresel1 = "where objetapp_usr.code_oa = objetapp.code_oa and oa_carac.code_oa = objetapp_usr.code_oa ";
            String wheresel2 = "and objetapp_usr.code_usr = p.code_usr and p.csdp_code = c.id_profile and val_car1 = id_temp_form and code_cw = '0000000005' and objetapp_usr.code_usr = '" + this.TEXTBOX_UTIL.Text + "' ";
            String sqlcom = selreq1 + fromsel1 + wheresel1 + wheresel2;
            string strSQLconnection = "Data Source=AGILP;User Id=PSSOFT;Password=PSSAGILP1020;";
            OracleConnection OConnexion = new OracleConnection();
            OConnexion.ConnectionString = strSQLconnection;
            // Ouverture de la connexion
            OConnexion.Open();
            OracleCommand cmd = new OracleCommand(sqlcom);
            cmd.Connection = OConnexion;
            OracleDataReader reader = cmd.ExecuteReader();
            GRIDVIEW_CHOIX_APPS.DataBind();*/
     
            //TEXTBOX2.Text = appc_code;
     
            //this.VISA_CHOIX_APP.AutoPostBack = true;
     
            //url = "/pssoft/itam/redir.aspx?target=ServiceManagementIncidentIncidentForm&EXTERNALINCIDENT=TRUE&code_usr=" + usercode + "&login=" + login + "&password=" + password + "&MODE=CREATEINCIDENTBYTYPE&AUTOFILLUSER=0&AUTOFILLCALLER=1&TICKETTYPE=" + appc_code;
     
            window_open = "window.open('" + url + "')";
     
            this.ButtonOK.Attributes.Add("onclick", window_open);
     
            String selreq1 = "select TO_CHAR(c.id_combo_value) as NUM_ECRAN, des_oa as LIB ";
            String fromsel1 = "from objetapp_usr, objetapp, oa_carac, csd_profile_templ_ticket_type c, password p ";
            String wheresel1 = "where objetapp_usr.code_oa = objetapp.code_oa and oa_carac.code_oa = objetapp_usr.code_oa ";
            String wheresel2 = "and objetapp_usr.code_usr = p.code_usr and p.csdp_code = c.id_profile and val_car1 = id_temp_form and code_cw = '0000000005' and objetapp_usr.code_usr = '" + this.TEXTBOX_UTIL.Text + "' ";
            String sqlcom = selreq1 + fromsel1 + wheresel1 + wheresel2;
     
            string strSQLconnection = "Data Source=AGILP;User Id=PSSOFT;Password=PSSAGILP1020;";
     
            OracleConnection OConnexion = new OracleConnection();
            OConnexion.ConnectionString = strSQLconnection;
            // Ouverture de la connexion
            OConnexion.Open();
            OracleCommand cmd = new OracleCommand(sqlcom);
            cmd.Connection = OConnexion;
            OracleDataReader reader = cmd.ExecuteReader();
     
            /*while (reader.Read())
            {
                this.SEL_COMPETENCES_COLL_SEL.Text = reader.GetString(0);
                this.VG_NOM_COLL.Text = reader.GetString(0);
            }*/
     
     
            GRIDVIEW_CHOIX_APPS.DataSource = reader;
     
            GRIDVIEW_CHOIX_APPS.DataBind();
     
            OConnexion.Close();
     
        }
    }

  2. #2
    Expert confirmé
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Par défaut
    Salut,

    Apparemment, c'est quelque chose de connu. Tu peux regarder ici: http://weblogs.sqlteam.com/markc/arc.../21/60848.aspx

    A+
    "Winter is coming" (ma nouvelle page d'accueil)

  3. #3
    Nouveau candidat au Club
    Inscrit en
    Août 2011
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Août 2011
    Messages : 2
    Par défaut
    euh et en français ça donne quoi car si je comprend bien, il faut juste une ligne avec code file or ceci est déjà présent :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="PageDynApp.aspx.cs" Inherits="_Default" %>

  4. #4
    Modérateur

    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Avril 2007
    Messages
    1 996
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 996
    Par défaut
    Bonjour,

    ou tu as bidouillé le nom de ta classe ou tu as ajouté ton code dans la mauvaise page.
    En effet, ton aspx est nommé (a priori) : PageDynApp.aspx. Normalement, tu devrais utiliser, pour le code, la page : PageDynApp.aspx.cs
    Or, dans ton cs, on voit : public partial class Default

    Donc, ou tu as changé "public partial class PageDynApp" en "public partial class Default" et il ne fallait pas le faire.
    Ou tu travailles dans la page Default.aspx.cs et il est alors normal que tu n'y vois pas les contrôles de PageDynApp.aspx.

    Dans le premier cas, renomme le nom de ta classe comme à l'origine : public partial class PageDynApp.
    Dans le second cas, travaille dans PageDynApp.aspx.cs

Discussions similaires

  1. Problème Gridview et paramètre dans l'URL
    Par krovomi dans le forum ASP.NET
    Réponses: 10
    Dernier message: 12/12/2009, 10h26
  2. Problème Gridview/Update : comportement incohérent
    Par mask_66 dans le forum VB.NET
    Réponses: 0
    Dernier message: 13/05/2009, 17h08
  3. Problème de bas de page
    Par milaybe dans le forum Rave
    Réponses: 15
    Dernier message: 28/06/2008, 09h37
  4. Problème cumul bas de page
    Par Titouwizz dans le forum SAP Crystal Reports
    Réponses: 0
    Dernier message: 28/03/2008, 13h45
  5. [WebForms][2.0] Problème GridView et HtmlEncode
    Par fix105 dans le forum ASP.NET
    Réponses: 3
    Dernier message: 13/11/2006, 15h15

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