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 :

[VB.Net] Comment éditer un DataList ?


Sujet :

ASP.NET

  1. #1
    Membre du Club
    Inscrit en
    Mai 2004
    Messages
    153
    Détails du profil
    Informations forums :
    Inscription : Mai 2004
    Messages : 153
    Points : 68
    Points
    68
    Par défaut [VB.Net] Comment éditer un DataList ?
    Bonjour à tous,

    j'au mis en place une requete parametrée ,l'affichage sur fait ds un datalist, avec un bouton pour editer le resultat.
    mais en cliquant sur le bouton pour editer rien ne se passe.

    ma page 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
    
    <asp:LabelID="Label1"runat="server"Text="Matricule :"></asp:Label>
    <asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
    <asp:ButtonID="Button1"runat="server"OnClick="getdata"Text="Button"/>
    
    <asp:DataListID="DataList1"runat="server"BackColor="LightGoldenrodYellow"RepeatColumns="1"BorderColor="Tan"BorderWidth="1px"CellPadding="2"ForeColor="Black">
    
     
    <ItemTemplate>
    <tr><td><asp:LabelID="Label2"runat="server"Text='<%# Container.DataItem("MAT") %>'></asp:Label></div>
    <tr><td> <%#Container.DataItem("agent")%> 
    <tr><td><asp:ButtonCommandName="Edit"Text="Edition"Runat="server"ID="Button2"/></td>
    </ItemTemplate>
    
    <EditItemTemplate>
    <inputtype="text"id="txtFirst"value='<%#Container.DataItem("agent")%>'runat="server"/>
    </EditItemTemplate>
    <FooterStyleBackColor="Tan"/>
    <SelectedItemStyleBackColor="DarkSlateBlue"ForeColor="GhostWhite"/>
    <AlternatingItemStyleBackColor="PaleGoldenrod"/>
    <HeaderStyleBackColor="Tan"Font-Bold="True"/>
    
    </asp:DataList>&nbsp;
    
     
    
    
    Mon code behind

    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
    
    Imports System
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports system.data
    Imports system.data.oledb
     
    Namespace aspx
    PublicClass recherche
     
    Inherits Page
    ProtectedWithEvents textbox1 As TextBox
    ProtectedWithEvents Label1 As Label
    ProtectedWithEvents DataList1 As DataList
    ProtectedWithEvents button1 As button
    ProtectedWithEvents Label2 As Label
    ProtectedWithEvents button2 As button
    ProtectedWithEvents txtFirst As TextBox
     
    Sub getdata(ByVal obj AsObject, ByVal e As System.EventArgs)
    Dim conn AsNew oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=C:\base\eval.mdb")
    Dim objcomm As OleDbcommand = New OleDbcommand _
    ("select * from tblagent_service where mat=@mat", conn)
    Dim objreader As oledbdatareader
    Dim objparam As oledbparameter
    objparam = objcomm.parameters.add("@textbox1", oledbtype.integer)
    objparam.direction = ParameterDirection.input
    objparam.value = textbox1.text
    Try
    objcomm.connection.open()
    objreader = objcomm.executereader
    Catch ex As oledbexception
    label1.text = "Ooooopss"
    EndTry
     
    DataList1.datasource = objreader
    DataList1.databind()
    objreader.close()
    objcomm.connection.close()
    EndSub
     
     
    Sub DataList1_EditCommand(ByVal source AsObject, ByVal e As DataListCommandEventArgs)
    DataList1.EditItemIndex = e.Item.ItemIndex
    datalist1.databind()
    EndSub
     
    EndClass
    EndNamespace
    
    a votre avis ou est le pb.

    merci

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    129
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2004
    Messages : 129
    Points : 103
    Points
    103
    Par défaut
    As-tu une requête d'Update ? Je ne suis pas sûre à 100% mais il me semble que si tu n'as pas de requête d'update le mode EDIT ne s'active pas.

  3. #3
    Membre du Club
    Inscrit en
    Mai 2004
    Messages
    153
    Détails du profil
    Informations forums :
    Inscription : Mai 2004
    Messages : 153
    Points : 68
    Points
    68
    Par défaut
    Citation Envoyé par steelidol
    As-tu une requête d'Update ? Je ne suis pas sûre à 100% mais il me semble que si tu n'as pas de requête d'update le mode EDIT ne s'active pas.
    je n'ai pas encore de requete update, mais je ne pense pas que ça soit a cause de ça.
    qd on clique sur le bouton edit ,je dois avoir des zones de sesies, cet évenement ne se produit pas

  4. #4
    Membre du Club
    Inscrit en
    Mai 2004
    Messages
    153
    Détails du profil
    Informations forums :
    Inscription : Mai 2004
    Messages : 153
    Points : 68
    Points
    68
    Par défaut
    alors, pas d'idée?

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 14
    Points : 14
    Points
    14
    Par défaut
    Avec cela , ca fonctionne :

    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
    Sub EditLigne( sendre as object ,  e As DataGridCommandEventArgs) 
     datalist.EditItemIndex = e.Item.ItemIndex 
     binddata() 
    End sub 
    
    
    <asp:Datalist ID="datalist" Width="200px" runat="server"  ShowFooter="true" OnEditCommand="EditLigne" OnUpdateCommand="maj"  OnItemCommand="choisir" OnCancelCommand="annulation" OnDeleteCommand="delete" AutoGenerateColumns="false" >
        <headerstyle BackColor="Brown" ForeColor="White"> </headerstyle>
        <itemstyle BackColor="#CCCCCC" ForeColor="#000000"></itemstyle>
        <footerstyle BackColor="#FF0000" ForeColor="#FFFFFF"></footerstyle>
    
            <ItemTemplate>
           <tr><td><asp:Label ID="Label2" runat="server" Text='<%# Container.DataItem("cat") %>'></asp:Label></div>
           <tr><td> <%#Container.DataItem("ID")%> 
           <tr><td><asp:Button CommandName="Edit" Text="Edition" Runat="server" ID="Button2"/></td>
           </ItemTemplate>
    
           <EditItemTemplate>
           <asp:TextBox id="textfirst" value='<%#Container.DataItem("ID")%>' runat="server"/>
    </EditItemTemplate>
    
      </asp:Datalist>
    [FONT='Times New Roman']
    [/FONT]
    [FONT='Times New Roman'][/FONT]
    [FONT='Times New Roman'][/FONT]

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

Discussions similaires

  1. [VB.NET]Comment Imprimer une form
    Par bernard06 dans le forum Windows Forms
    Réponses: 4
    Dernier message: 19/10/2011, 17h43
  2. Réponses: 2
    Dernier message: 02/05/2006, 09h50
  3. Réponses: 16
    Dernier message: 22/03/2005, 21h57
  4. [vb.net] Comment vider un buffer ?
    Par mdc dans le forum Windows Forms
    Réponses: 4
    Dernier message: 16/12/2003, 15h43
  5. [VB.Net] Comment generer une page html dynamiquement ?
    Par Anonymous dans le forum ASP.NET
    Réponses: 3
    Dernier message: 13/03/2003, 10h22

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