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 :

probleme saisie d'un formulaire


Sujet :

ASP.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Étudiant
    Inscrit en
    Avril 2010
    Messages
    49
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2010
    Messages : 49
    Par défaut probleme saisie d'un formulaire
    bonjour,
    je realise une application web sous visual studio en asp.net vb.
    lors de la saisie d'un formulaire j'ai un message d'erreur me montrant mon code ce message m'indique :
    [IMG]H:\Sauvegardes\messerreurappli.JPG[/IMG]

    l'exception format exception n'a pas été gérée par le code utilisateur.
    la chaine doit avoir une longeur d'un et un seul caractere

    conseil de depannage :
    assurez vous que le format des arguments de votre methode est correct.
    lors de la convertion d'une chaine en objet datetime, analyser la chaine pour prendre la date avant de la placer chaque variable dans l'objet datetime.
    je pense que le probleme vient du format date mais j'ai regarder dans mon code et dans ma base c'est le meme format "datetime"

    pour selection la date dans mon formmulaire, j'utilise un calendar.

    y a t'il une personne ayant une solution s'il vous plait ?
    merci
    cordialement.

  2. #2
    Membre éclairé Avatar de Nicopilami
    Profil pro
    Ingénieur sécurité
    Inscrit en
    Janvier 2009
    Messages
    354
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur sécurité

    Informations forums :
    Inscription : Janvier 2009
    Messages : 354
    Par défaut
    salut Yassin, peux-tu mettre un bout du code ? sans cela, difficile de t'aider...

    bye
    Nico

  3. #3
    Membre averti
    Étudiant
    Inscrit en
    Avril 2010
    Messages
    49
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2010
    Messages : 49
    Par défaut
    salut nicipilami,

    lorsque le message d'erreur s'affiche, il m'indique la fonction sqldatasource_inserted

    voici le code de la page concerné pdp.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
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
     
     <asp:TemplateField
                HeaderText="Localisation"
                SortExpression="Localisation">
                <InsertItemTemplate>
                    <asp:TextBox
                        ID="IdLocalisationTextBox"
                        runat="server"
                        Text='<%# Bind("idLocalisation") %>'
                        Visible="false" />
                    <asp:DropDownList
                        ID="DropDownListLocalisation"
                        runat="server"
                        AppendDataBoundItems="true"
                        AutoPostBack="true"
                        DataSourceID="SqlDataSourceLocalisation"
                        DataTextField="NomLocalisation"
                        DataValueField="idLocalisation"
                        OnSelectedIndexChanged="DropDownListLocalisation_SelectedIndexChanged"
                        Width="98%">
                        <asp:ListItem>
                        </asp:ListItem>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator
                        ID="RequiredFieldValidator2"
                        runat="server"
                        ControlToValidate="DropDownListLocalisation"
                        Display="Dynamic"
                        ErrorMessage="Champ obligatoire" />
                </InsertItemTemplate>
                <HeaderStyle
                    Width="180px" />
                <ItemTemplate>
                    <asp:Label
                        ID="Label5"
                        runat="server"
                        Text='<%# Bind("NomLocalisation") %>' />
                    <asp:Label
                        ID="LabelIdLocalisation"
                        runat="server"
                        Text='<%# Bind("idLocalisation") %>'
                        Visible="false" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField
                HeaderText="Numero"
                SortExpression="Numero">
                <EditItemTemplate>
                    <asp:TextBox
                        ID="TextBoxNumero"
                        runat="server"
                        CssClass="textcenter"
                        MaxLength="50"
                        Text='<%# Bind("Numero") %>'
                        Width="80px" />
                    <asp:ImageButton
                        ID="ImageButtonFindNumber"
                        runat="server"
                        OnClick="ImageButtonFindNumber_Click"
                        SkinID="Find"
                        ToolTip="Trouver le numéro automatiquement" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox
                        ID="TextBoxNumero"
                        runat="server"
                        CssClass="textcenter"
                        MaxLength="50"
                        Text='<%# Bind("Numero") %>'
                        Width="80px" />
                    <asp:ImageButton
                        ID="ImageButtonFindNumber"
                        runat="server"
                        OnClick="ImageButtonFindNumber_Click"
                        SkinID="Find"
                        ToolTip="Trouver le numéro automatiquement" />
                </InsertItemTemplate>
                <HeaderStyle
                    Width="180px" />
                <ItemTemplate>
                    <asp:Label
                        ID="LabelNumero"
                        runat="server"
                        Text='<%# Bind("Numero") %>'
                        Width="80px" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField
                HeaderText="Intitule"
                SortExpression="Intitule">
                <EditItemTemplate>
                    <asp:TextBox
                        ID="TextBox2"
                        runat="server"
                        MaxLength="1000"
                        Text='<%# Bind("Intitule") %>' />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox
                        ID="TextBox2"
                        runat="server"
                        MaxLength="1000"
                        Text='<%# Bind("Intitule") %>'
                        Width="98%" />
                </InsertItemTemplate>
                <HeaderStyle
                    Width="180px" />
                <ItemTemplate>
                    <asp:Label
                        ID="Label2"
                        runat="server"
                        Text='<%# Bind("Intitule") %>'
                        Width="98%" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField
                HeaderText="Signature donneur d'ordre"
                SortExpression="DateSignatureDO">
                <EditItemTemplate>
                    <asp:TextBox
                        ID="TextBox_DateSignatureDO"
                        runat="server"
                        CssClass="textcenter"
                        Text='<%# Bind("DateSignatureDO", "{0:d}") %>'
                        Width="80px" />
                    <asp:ImageButton
                        ID="ImageButton_DateSignatureDO"
                        runat="server"
                        CausesValidation="false"
                        OnClick="ImageButton_Calendar_Click"
                        SkinID="Calendar" />
                    <asp:Panel
                        ID="Panel_DateSignatureDO"
                        runat="server"
                        Visible="false"
                        Width="200px">
                        <div style="margin: 7px">
                            <asp:Calendar
                                ID="Calendar_DateSignatureDO"
                                runat="server"
                                OnSelectionChanged="Calendar_SelectionChanged">
                            </asp:Calendar>
                        </div>
                    </asp:Panel>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox
                        ID="TextBox_DateSignatureDO"
                        runat="server"
                        CssClass="textcenter"
                        Text='<%# Bind("DateSignatureDO", "{0:d}") %>'
                        Width="80px" />
                    <asp:ImageButton
                        ID="ImageButton_DateSignatureDO"
                        runat="server"
                        CausesValidation="false"
                        OnClick="ImageButton_Calendar_Click"
                        SkinID="Calendar" />
                    <asp:Panel
                        ID="Panel_DateSignatureDO"
                        runat="server"
                        Visible="false"
                        Width="200px">
                        <div style="margin: 7px">
                            <asp:Calendar
                                ID="Calendar_DateSignatureDO"
                                runat="server"
                                OnSelectionChanged="Calendar_SelectionChanged">
                            </asp:Calendar>
                        </div>
                    </asp:Panel>
                </InsertItemTemplate>
                <HeaderStyle
                    Width="180px" />
                <ItemTemplate>
                    <asp:Label
                        ID="Label5"
                        runat="server"
                        Text='<%# Bind("DateSignatureDO", "{0:d}") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField
                HeaderText="Signature entreprise exterieure"
                SortExpression="DateSignatureEE">
                <EditItemTemplate>
                    <asp:TextBox
                        ID="TextBox_DateSignatureEE"
                        runat="server"
                        CssClass="textcenter"
                        Text='<%# Bind("DateSignatureEE", "{0:d}") %>'
                        Width="80px" />
                    <asp:ImageButton
                        ID="ImageButton_DateSignatureEE"
                        runat="server"
                        CausesValidation="false"
                        OnClick="ImageButton_Calendar_Click"
                        SkinID="Calendar" />
                    <asp:Panel
                        ID="Panel_DateSignatureEE"
                        runat="server"
                        Visible="false"
                        Width="200px">
                        <div style="margin: 7px">
                            <asp:Calendar
                                ID="Calendar_DateSignatureEE"
                                runat="server"
                                OnSelectionChanged="Calendar_SelectionChanged">
                            </asp:Calendar>
                        </div>
                    </asp:Panel>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox
                        ID="TextBox_DateSignatureEE"
                        runat="server"
                        CssClass="textcenter"
                        Text='<%# Bind("DateSignatureEE", "{0:d}") %>'
                        Width="80px" />
                    <asp:ImageButton
                        ID="ImageButton_DateSignatureEE"
                        runat="server"
                        CausesValidation="false"
                        OnClick="ImageButton_Calendar_Click"
                        SkinID="Calendar" />
                    <asp:Panel
                        ID="Panel_DateSignatureEE"
                        runat="server"
                        Visible="false"
                        Width="200px">
                        <div style="margin: 7px">
                            <asp:Calendar
                                ID="Calendar_DateSignatureEE"
                                runat="server"
                                OnSelectionChanged="Calendar_SelectionChanged">
                            </asp:Calendar>
                        </div>
                    </asp:Panel>
                </InsertItemTemplate>
                <HeaderStyle
                    Width="180px" />
                <ItemTemplate>
                    <asp:Label
                        ID="Label6"
                        runat="server"
                        Text='<%# Bind("DateSignatureEE", "{0:d}") %>' />
                </ItemTemplate>
            </asp:TemplateField>
        </Fields>
    </asp:DetailsView>
    <asp:Panel
        ID="PanelI"
        Width="100%"
        runat="server"
        visible="false">
        <br />
        <table width="100%">
            <tr>
                <td style="text-align: center">
                    <asp:LinkButton
                        Text="Enregistrer et compléter"
                        runat="server"
                        ID="LinkButtonINsertAndEdit" /></td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel
        Width="100%"
        runat="server"
        ID="PanelRW"
        Visible="false">
        <br />
        <asp:Panel
            Width="100%"
            ID="Panel2"
            runat="server"
            GroupingText="Intervenants soumis au plan de prévention">
            <div class="panelcontent">
                <uc:IntervenantPDP
                    ID="IntervenantPDPUC"
                    runat="server" />
            </div>
        </asp:Panel>
        <br />
        <uc:AvenantPDP
            ID="AvenantPDPUC"
            runat="server" />
        <br />
        <uc:Document
            ID="DocumentUC"
            runat="server" />
    </asp:Panel>
    <asp:SqlDataSource
        ID="SqlDataSourcePDP"
        runat="server"
        ConnectionString="<%$ ConnectionStrings:PDP %>"
        DeleteCommand="DELETE FROM [PDP] WHERE [idPDP] = @idPDP"
        InsertCommand="INSERT INTO [PDP] ([idDocument], [idEntreprise], [IdLocalisation], [Numero], [Intitule], [DateSignatureDO],[DateSignatureEE]) VALUES (@idDocument, @idEntreprise, @IdLocalisation, @Numero, @Intitule,@DateSignatureDO,@DateSignatureEE) SET @Identity = @@Identity"
        OnInserted="SqlDataSourcePDP_Inserted"
        OnInserting="SqlDataSourcePDP_Inserting"
        SelectCommand="SELECT PDP.idPDP, PDP.idDocument, PDP.Numero, PDP.Intitule,  PDP.DateSignatureDO, PDP.DateSignatureEE, PDP.idEntreprise, PDP.IdLocalisation, Localisation.NomLocalisation, Entreprise.Nom, CAST(1 AS bit) AS AllowEdit  FROM DonneurOrdreCommande INNER JOIN Commande ON DonneurOrdreCommande.idCommande = Commande.idCommande RIGHT OUTER JOIN PDP INNER JOIN Localisation ON PDP.IdLocalisation = Localisation.IdLocalisation INNER JOIN Entreprise ON PDP.idEntreprise = Entreprise.idEntreprise   ON Commande.idPDP = PDP.idPDP WHERE (PDP.idPDP = @idPDP) AND (DonneurOrdreCommande.idDonneurOrdre = @UserID) OR (PDP.idPDP = @idPDP) AND (DonneurOrdreCommande.idDonneurOrdre IS NULL) AND (@UserID &gt;= 0) OR (PDP.idPDP = @idPDP)  AND (@UserID = 0) UNION SELECT PDP_1.idPDP, PDP_1.idDocument, PDP_1.Numero, PDP_1.Intitule, PDP_1.DateSignatureDO, PDP_1.DateSignatureEE, PDP_1.idEntreprise, Entreprise_1.Nom,PDP_1.IdLocalisation, Localisation_1.NomLocalisation, CAST(0 AS bit) AS AllowEdit FROM PDP AS PDP_1 INNER JOIN Entreprise AS Entreprise_1 ON PDP_1.idEntreprise = Entreprise_1.idEntreprise INNER JOIN LOCALISATION AS Localisation_1 ON PDP_1.IdLocalisation = Localisation_1.IdLocalisation INNER JOIN Commande AS Commande_1 ON PDP_1.idPDP = Commande_1.idPDP INNER JOIN DonneurOrdreCommande AS DonneurOrdreCommande_1 ON Commande_1.idCommande = DonneurOrdreCommande_1.idCommande WHERE (PDP_1.idPDP = @idPDP) AND (DonneurOrdreCommande_1.idDonneurOrdre &lt;&gt; @UserID) AND (NOT (DonneurOrdreCommande_1.idDonneurOrdre IS NULL)) AND (@UserID &lt;&gt; 0) OR (PDP_1.idPDP = @idPDP) AND (@UserID &lt; 0)"
     
     
        UpdateCommand="UPDATE [PDP] SET [idEntreprise] = @idEntreprise, [IdLocalisation] = @IdLocalisation, [Numero] = @Numero, [Intitule] = @Intitule, [DateSignatureDO] = @DateSignatureDO, [DateSignatureEE] = @DateSignatureEE WHERE [idPDP] = @idPDP">
        <DeleteParameters>
            <asp:Parameter
                Name="idPDP"
                Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter
                Name="idEntreprise"
                Type="Int32" />
            <asp:Parameter
                Name="IdLocalisation" 
                Type="Int32" />
            <asp:Parameter
                Name="Numero"
                Type="char" />
            <asp:Parameter
                Name="Intitule"
                Type="char" />
            <asp:Parameter
                Name="DateSignatureDO"
                Type="DateTime" />
            <asp:Parameter
                Name="DateSignatureEE"
                Type="DateTime" />
            <asp:Parameter
                Name="idPDP"
                Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter
                Name="idDocument"
                Type="Int32" />
            <asp:Parameter
                Name="idEntreprise"
                Type="Int32" />
            <asp:Parameter
                Name="IdLocalisation" 
                Type="Int32" />
            <asp:Parameter
                Name="Numero"
                Type="char" />
            <asp:Parameter
                Name="Intitule"
                Type="char" />
            <asp:Parameter
                Name="DateSignatureDO"
                Type="DateTime" />
            <asp:Parameter
                Name="DateSignatureEE"
                Type="DateTime" />
            <asp:Parameter
                Name="Identity" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter
                ControlID="ParamidPDP"
                DefaultValue="-1"
                Name="idPDP"
                PropertyName="Text"
                Type="Int32" />
            <asp:SessionParameter
                Name="UserID"
                SessionField="UserID"
                DefaultValue="-1" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource
        ID="SqlDataSourceEntreprise"
        runat="server"
        ConnectionString="<%$ ConnectionStrings:PDP %>"
        SelectCommand="SELECT [Nom], [idEntreprise] FROM [Entreprise] ORDER BY [Nom]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourceLocalisation" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PDP %>" 
        SelectCommand="SELECT [IdLocalisation], [NomLocalisation] FROM [Localisation] ORDER BY [NomLocalisation]">
    </asp:SqlDataSource>
    et voici le code vb de cette page :

    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
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
     
     
    Partial Class Modules_PDP
        Inherits System.Web.UI.UserControl
     
        Public Function InitMode(ByVal Mode As FormViewMode, Optional ByVal idPDP As String = "-1") As Boolean
            InitMode = True
            On Error Resume Next
            ViewState.Clear()
     
            If IsNumeric(idPDP) Then ParamidPDP.Text = idPDP
            DetailsViewPDP.ChangeMode(Mode)
            DetailsViewPDP.DataBind()
     
            InitMode = (DetailsViewPDP.DataItemCount > 0 Or Mode = DetailsViewMode.Insert)
            If InitMode Then
                Dim idDocument As String
                Dim AllowEdit As Boolean
     
                idDocument = CType(DetailsViewPDP.FindControl("LabelidDocument"), Label).Text
                AllowEdit = CBool(CType(DetailsViewPDP.FindControl("LabelAllowEdit"), Label).Text)
     
                If Not AllowEdit And Mode = FormViewMode.Edit Then
                    InitMode = InitMode(FormViewMode.ReadOnly, idPDP)
                Else
                    Select Case DetailsViewPDP.CurrentMode
                        Case FormViewMode.ReadOnly
                            PanelRW.Visible = True
                            PanelI.Visible = False
                            IntervenantPDPUC.InitMode(FormViewMode.ReadOnly, idPDP)
                            DocumentUC.InitMode(FormViewMode.ReadOnly, idDocument)
                            AvenantPDPUC.InitMode(FormViewMode.ReadOnly, idPDP)
                        Case FormViewMode.Edit
                            PanelRW.Visible = True
                            PanelI.Visible = False
                            IntervenantPDPUC.InitMode(FormViewMode.Edit, idPDP)
                            DocumentUC.InitMode(FormViewMode.Edit, idDocument)
                            AvenantPDPUC.InitMode(FormViewMode.Edit, idPDP)
                        Case DetailsViewMode.Insert
                            PanelRW.Visible = False
                            PanelI.Visible = True
                    End Select
                End If
            Else
                InitMode = (DetailsViewPDP.DataItemCount > 0)
            End If
     
        End Function
     
        Public Function SaveAndGetID() As Integer
            If DetailsViewPDP.CurrentMode = FormViewMode.Edit Then
                DetailsViewPDP.UpdateItem(False)
            ElseIf DetailsViewPDP.CurrentMode = FormViewMode.Insert Then
                DetailsViewPDP.InsertItem(False)
            End If
            Try
                SaveAndGetID = CInt(ParamidPDP.Text)
            Catch ex As Exception
                SaveAndGetID = -1
            End Try
        End Function
     
        Public Function CurrentMode() As FormViewMode
            CurrentMode = DetailsViewPDP.CurrentMode
        End Function
     
        Public Shared Sub DeleteID(ByVal idPDP As String)
            Dim idDocument As String
            idDocument = ExecuteSQL("Select idDocument From PDP WHERE idPDP = " & idPDP).ToString
            Modules_Document.DeleteID(idDocument)
            ExecuteSQL("Delete From PDP where idPDP = " & idPDP)
        End Sub
     
        Protected Sub DropDownListEntreprise_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim txtEntreprise As TextBox = CType(DetailsViewPDP.FindControl("IdEntrepriseTextBox"), TextBox)
            Dim ddlEntreprise As DropDownList = CType(DetailsViewPDP.FindControl("DropDownListEntreprise"), DropDownList)
            Dim NumTextBox As TextBox = CType(DetailsViewPDP.FindControl("TextBoxNumero"), TextBox)
            txtEntreprise.Text = ddlEntreprise.SelectedValue
            If NumTextBox.Text = "" Then ImageButtonFindNumber_Click(Nothing, Nothing)
     
        End Sub
        Protected Sub DropDownListLocalisation_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim txtLocalisation As TextBox = CType(DetailsViewPDP.FindControl("IdLocalisationTextBox"), TextBox)
            Dim ddlLocalisation As DropDownList = CType(DetailsViewPDP.FindControl("DropDownListLocalisation"), DropDownList)
            Dim NumTextBox As TextBox = CType(DetailsViewPDP.FindControl("TextBoxNumero"), TextBox)
            txtLocalisation.Text = ddlLocalisation.SelectedValue
            If NumTextBox.Text = "" Then ImageButtonFindNumber_Click(Nothing, Nothing)
        End Sub
     
        Protected Sub SqlDataSourcePDP_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)
            ParamidPDP.Text = e.Command.Parameters("@Identity").Value
        End Sub
     
        Protected Sub SqlDataSourcePDP_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
            e.Command.Parameters("@idDocument").Value = Outils.ExecuteSQL("Insert Into Document (Type) values ('PDP') Select @@Identity").ToString
        End Sub
     
        Public Sub SetEntreprise(ByVal idEntreprise As Integer)
            Dim ddlEntreprise As DropDownList = CType(DetailsViewPDP.FindControl("DropDownListEntreprise"), DropDownList)
            ddlEntreprise.SelectedValue = idEntreprise.ToString
            DropDownListEntreprise_SelectedIndexChanged(ddlEntreprise, Nothing)
            ddlEntreprise.Enabled = False
        End Sub
        Public Sub SetLocalisation(ByVal idLocalisation As Integer)
            Dim ddlLocalisation As DropDownList = CType(DetailsViewPDP.FindControl("DropDownListLocalisation"), DropDownList)
            ddlLocalisation.SelectedValue = idLocalisation.ToString
            DropDownListLocalisation_SelectedIndexChanged(ddlLocalisation, Nothing)
            ddlLocalisation.Enabled = False
        End Sub
     
        Sub ImageButtonFindNumber_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
            Dim idEntreprise As Object
     
            Try
                idEntreprise = CType(DetailsViewPDP.FindControl("DropDownListEntreprise"), DropDownList).SelectedValue
     
            Catch ex As Exception
                idEntreprise = CType(DetailsViewPDP.FindControl("LabelIdEntreprise"), Label).Text
     
            End Try
            Dim NumTextBox As TextBox = CType(DetailsViewPDP.FindControl("TextBoxNumero"), TextBox)
            Dim num As Object = Nothing
            If Not IsNothing(idEntreprise) Then
                num = ExecuteSQL("Select max(Numero) From PDP Where idEntreprise = " & idEntreprise)
            End If
            If Not IsNumeric(num) Then
                num = ExecuteSQL("Select max(Numero) From PDP")
                If IsNothing(num) Then
                    num = "1"
                ElseIf IsNumeric(num) Then
                    num = CDec(num) + 1
                Else
                    num = "(" & num.ToString & ")"
                End If
            End If
            NumTextBox.Text = num.ToString
        End Sub
     
     
        Sub ImageButton_Calendar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
            Outils.ImageButton_Calendar_Click(sender, e)
        End Sub
     
        Protected Sub Calendar_Init(ByVal sender As Object, ByVal e As System.EventArgs)
            Outils.Calendar_Init(sender, e)
        End Sub
     
        Protected Sub Calendar_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
            Outils.Calendar_SelectionChanged(sender, e)
        End Sub
     
        Protected Sub LinkButtonINsertAndEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonINsertAndEdit.Click
            InitMode(FormViewMode.Edit, SaveAndGetID())
        End Sub
     
    End Class

  4. #4
    Membre averti
    Étudiant
    Inscrit en
    Avril 2010
    Messages
    49
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2010
    Messages : 49
    Par défaut
    bonjour,
    jen'est toujours pas trouvé j'ai pourtant regardé dans ma base de donnée et le type est le meme dans mes requete je ne trouve pas d'erreur.
    qu'elle peut etre la source du probleme s'il vous plait ?

  5. #5
    Membre éclairé Avatar de Nicopilami
    Profil pro
    Ingénieur sécurité
    Inscrit en
    Janvier 2009
    Messages
    354
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur sécurité

    Informations forums :
    Inscription : Janvier 2009
    Messages : 354
    Par défaut
    Citation Envoyé par yassin-59 Voir le message
    bonjour,
    jen'est toujours pas trouvé j'ai pourtant regardé dans ma base de donnée et le type est le meme dans mes requete je ne trouve pas d'erreur.
    qu'elle peut etre la source du probleme s'il vous plait ?
    Hello
    je ne connais pas trop le VB.NET, mais par contre, peux-tu préciser le message d'erreur ?

  6. #6
    Membre averti
    Étudiant
    Inscrit en
    Avril 2010
    Messages
    49
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2010
    Messages : 49
    Par défaut
    bonjour,

    le message d'erreur m'indique :
    l'exception format exception n'a pas été gérée par le code utilisateur.
    la chaine doit avoir une longeur d'un et un seul caractere

    conseil de depannage :
    assurez vous que le format des arguments de votre methode est correct.
    lors de la convertion d'une chaine en objet datetime, analyser la chaine pour prendre la date avant de la placer chaque variable dans l'objet datetime.
    il s'affiche surt cette procedure :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    Public Function SaveAndGetID() As Integer
            If DetailsViewPDP.CurrentMode = FormViewMode.Edit Then
                DetailsViewPDP.UpdateItem(False)
            ElseIf DetailsViewPDP.CurrentMode = FormViewMode.Insert Then
                DetailsViewPDP.InsertItem(False)
            End If
            Try
                SaveAndGetID = CInt(ParamidPDP.Text)
            Catch ex As Exception
                SaveAndGetID = -1
            End Try
        End Function
    l'erreur pointe sur le detailsviewpdp.insertitem(false)

    j'ai analysé mon code mais je n'arrive pas a trouver l'erreur.

    cordialement

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [MySQL] Probleme saisie données formulaire
    Par ZeLaatar dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 02/12/2007, 12h26
  2. Réponses: 16
    Dernier message: 17/06/2005, 15h51
  3. Probleme d'envoie de formulaire
    Par wollverine dans le forum Balisage (X)HTML et validation W3C
    Réponses: 6
    Dernier message: 02/02/2005, 16h29
  4. Probleme d'ouverture de formulaire
    Par nemesys971 dans le forum IHM
    Réponses: 11
    Dernier message: 01/02/2005, 15h08
  5. Réponses: 2
    Dernier message: 11/12/2004, 21h20

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