begin process at 2012 05 27 18:50:46
  Trouver un code source :
 
dans
 
Accueil > Forum > 

ASP / ASP3

 > 

Web 2.0

 > 

Ajax

 > 

Création/Supression ligne de requete dynamique


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Création/Supression ligne de requete dynamique

vendredi 29 décembre 2006 à 15:24:13 | Création/Supression ligne de requete dynamique

heryibonia

Salut,
      J'aimerai créer dynamiquement plusieurs lugnes de requetes en asp .net et Ajax. durant le chargement de la page Page_Load, on créer la première ligne.
 AddPanel(1)
        For i As Integer = 2 To PanelCount
            AddPanel(i)
        Next
ensuite dans la première ligne, il y a un bouton d'ajout pour le deuxième et le bouton suivant
? Comment fait on avoir les valeurs des controls de chaue lignes de requetes
je vou envoie le code
********************Code************************
Private Sub AddPanel(ByVal i As Integer)

        If i = 1 Then
            Dim btnAdd As New Button()
            With btnAdd
                .ID = "btn" & i
                .Text = "Bouton" & i
                .Width = Unit.Pixel(70).Value
                AddHandler btnAdd.Click, AddressOf AddNewLine_Click
            End With


            'Dim btnClear As New Button()
            'With btnClear
            '    .ID = "Clear" & i
            '    .Text = "Clear" & i
            '    .Width = Unit.Pixel(50).Value
            '    .Enabled = False
            '    AddHandler btnClear.Click, AddressOf ClearHandler_Click
            'End With


            Dim dbr As New DataStructureReader.DbStructureReader(AppSettings("XmlFile"))

            Dim drpList1 As New DropDownList()
            With drpList1
                .ID = "DropDownList1" & i
                '.DataSource = dbr.GetColumnsListByMainTableClass("Person")
                '.DataTextField = "DisplayName"
                '.DataValueField = "Property"
                .Items.Add("ET")
                .Items.Add("OU")
                .Width = Unit.Pixel(50).Value
                .DataBind()
                .Enabled = False
            End With


            Dim drpList2 As New DropDownList()
            With drpList2
                .ID = "DropDownList2" & i
                .DataSource = dbr.GetColumnsListByMainTableClass("Person")
                .DataTextField = "DisplayName"
                .DataValueField = "Property"
                .Width = Unit.Pixel(200).Value
                .DataBind()
            End With


            Dim drpList3 As New DropDownList()
            With drpList3
                .ID = "DropDownList3" & i
                .DataSource = dbr.GetColumnsListByMainTableClass("Person")
                .DataTextField = "DisplayName"
                .DataValueField = "Property"
                .Width = Unit.Pixel(200).Value
                .DataBind()
            End With


            Dim TxtSql As New TextBox()
            With TxtSql
                .ID = "TxtSql" & i
                .Text = "TextBox" & i
                .Width = Unit.Pixel(120).Value
            End With


            Dim tbl As New Table
            Dim rw As New TableRow
            If tbl.GetType().ToString.Equals("System.Web.UI.WebControls.Table") Then
                With tbl
                    .ID = "Table" & i
                    .EnableViewState = True
                    .BorderWidth = Unit.Pixel(1)
                    .CellSpacing = 0
                    .CellPadding = 1
                    .Width = Unit.Percentage(100)
                End With


                'Dim cll1 As New TableCell
                'cll1.Controls.Add(btnClear)

                Dim cll2 As New TableCell
                cll2.Controls.Add(btnAdd)

                Dim cll3 As New TableCell
                cll3.Controls.Add(drpList1)

                Dim cll4 As New TableCell
                cll4.Controls.Add(drpList2)

                Dim cll5 As New TableCell
                cll4.Controls.Add(drpList3)

                Dim cll6 As New TableCell
                cll4.Controls.Add(TxtSql)

                With rw
                    '.Cells.Add(cll1)
                    .Cells.Add(cll2)
                    .Cells.Add(cll3)
                    .Cells.Add(cll4)
                    .Cells.Add(cll5)
                    .Cells.Add(cll6)
                End With


                tbl.Controls.Add(rw)
            End If
            place.Controls.Add(tbl)
        Else
            Dim btnAdd As New Button()
            With btnAdd
                .ID = "btn" & i
                .Text = "Bouton" & i
                .Width = Unit.Pixel(70).Value
                AddHandler btnAdd.Click, AddressOf AddNewLine_Click
            End With


            Dim btnClear As New Button()
            With btnClear
                .ID = "Clear" & i
                .Text = "Clear" & i
                .Width = Unit.Pixel(50).Value
                AddHandler btnClear.Click, AddressOf ClearHandler_Click
            End With


            Dim dbr As New DataStructureReader.DbStructureReader(AppSettings("XmlFile"))

            Dim drpList1 As New DropDownList()
            With drpList1
                .ID = "DropDownList1" & i
                '.DataSource = dbr.GetColumnsListByMainTableClass("Person")
                '.DataTextField = "DisplayName"
                '.DataValueField = "Property"
                .Items.Add("ET")
                .Items.Add("OU")
                .Width = Unit.Pixel(50).Value
                .DataBind()
            End With


            Dim drpList2 As New DropDownList()
            With drpList2
                .ID = "DropDownList2" & i
                .DataSource = dbr.GetColumnsListByMainTableClass("Person")
                .DataTextField = "DisplayName"
                .DataValueField = "Property"
                .Width = Unit.Pixel(200).Value
                .DataBind()
            End With


            Dim drpList3 As New DropDownList()
            With drpList3
                .ID = "DropDownList3" & i
                .DataSource = dbr.GetColumnsListByMainTableClass("Person")
                .DataTextField = "DisplayName"
                .DataValueField = "Property"
                .Width = Unit.Pixel(200).Value
                .DataBind()
            End With


            Dim TxtSql As New TextBox()
            With TxtSql
                .ID = "TxtSql" & i
                .Text = "TextBox" & i
                .Width = Unit.Pixel(120).Value
            End With


            Dim tbl As New Table
            Dim rw As New TableRow
            If tbl.GetType().ToString.Equals("System.Web.UI.WebControls.Table") Then
                With tbl
                    .ID = "Table" & i
                    .EnableViewState = True
                    .BorderWidth = Unit.Pixel(1)
                    .CellSpacing = 0
                    .CellPadding = 1
                    .Width = Unit.Percentage(100)
                End With


                Dim cll1 As New TableCell
                cll1.Controls.Add(btnClear)

                Dim cll2 As New TableCell
                cll2.Controls.Add(btnAdd)

                Dim cll3 As New TableCell
                cll3.Controls.Add(drpList1)

                Dim cll4 As New TableCell
                cll4.Controls.Add(drpList2)

                Dim cll5 As New TableCell
                cll4.Controls.Add(drpList3)

                Dim cll6 As New TableCell
                cll4.Controls.Add(TxtSql)

                With rw
                    .Cells.Add(cll1)
                    .Cells.Add(cll2)
                    .Cells.Add(cll3)
                    .Cells.Add(cll4)
                    .Cells.Add(cll5)
                    .Cells.Add(cll6)
                End With


                tbl.Controls.Add(rw)
            End If
            place.Controls.Add(tbl)
        End If
      
    End Sub

    Private Sub btnClearAllControls_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        ' Clear all the controls.
        place.Controls.Clear()

        ' Reset the number of controls.
        PanelCount = 0
    End Sub

    Private Sub ClearHandler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ' Reset the number of controls.
        'If TypeOf sender Is Button Then
        If place.Controls.Count > 0 Then
            If PanelCount >= 2 Then
                place.Controls.RemoveAt(place.Controls.Count - 1)
                PanelCount -= 1
            Else
                MsgBox("Pas de Bouton supplementaire")
            End If
        End If
        'End If
    End Sub

    Private Sub AddNewLine_Click(ByVal sender As Object, ByVal e As EventArgs)
        'Vérifier d'abord que le type de control qui envoye l'écènement
        'est un bouton. Ceci est primordiale avant que ce control soit
        'attache à ce type d'évènement

        If TypeOf sender Is Button Then
            If PanelCount < 10 Then
                PanelCount += 1
                AddPanel(PanelCount)
            End If
        Else
            MsgBox("Ce ci n'est pas un bouton")
        End If
    End Sub

    Private Property PanelCount() As Integer
        Get
            PanelCount = 1
            If ViewState("PanelCount") IsNot Nothing Then
                PanelCount = CType(ViewState("PanelCount"), Integer)
            End If
            Return PanelCount
        End Get

        Set(ByVal value As Integer)
            ViewState("PanelCount") = value
        End Set
    End Property
********************************Code*********************
Merci


Cette discussion est classée dans : end, add, controls, with, unit


Répondre à ce message

Sujets en rapport avec ce message

Validation d'un formulaire contenant 2 users controls [ par Anksunamon ] Bonjour à tous...Voici une question qui pourrait intéresser pas mal de monde... je m'explique...J'ai une page default.aspx qui appelle 2 users control Multiple controls with the same ID [ par systemic_anomaly ] Bonjour tt le monde,J'utilise un place holder et j'ajoute un control (TableMenu). Pas de problème lors du page load mais au postback j'ai ce message d Link button asp.net [ par abdo_dotnet10 ] Salut tout le mondej'essaye de creer des linkButton d'une maniere dynamique, pour les 2 premiers ça marche(ça veux dire lorsque je clique sur le linkb Controls.Add et Findcontrol [ par slednet69 ] 'lut,Je me permet une petite question sur le forum car je vais devenir fou....Jusqu'à maintenant en VS2003, lorsque je voulais ajouter dynamiquement d dropdownlist et textbox ajoutées en C# [ par Sabine25 ] Bonjour,j ai un petit soucis concernant des DDL et TBX.J ai toujours aujouter des textbox et ddl avec le toolbox.maintenant je veux faire un formulair DropDownList chargé de la base de donnée sans valeur par défaut [ par TIKATKT ] Bonjour tout le monde, J'ai commencé un petit projet en asp.net. Dans une page, j'ai mis deux DropDownList : DdlType et DdlCategorie. DdlType est cha Disposition lors d'un "Controls.Add" [ par stephsk09 ] Bonjour, ma question est simble, je crée dynamiquement un certain nombre de Gridview Variable.Je les affiche a l'écran grace a la méthode Controls.Add Rechargement contrôles dynamique [ par vinz64 ] Bonjour,J'ai ajouté des contrôles dynamique à ma page.aspx lorsque j'effectue une sélection sur une DropDownList. Donc dans l'évènement SelectedIndexC Aspsmartmail - Inclure dans l'envoi de mail une adresse qui a été saisie dans un champ du formulaire [ par webmast3rism ] Bonjour,Mon souhait est le suivant:J'ai une page .aspx dans laquelle j'ai un formulaire que des participants remplissent avec des informations classiq


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,499 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales