Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load tableName1 = Request.Params("tableName") 'Response.Write(tableName1) cn.ConnectionString = "Data Source=DESKTOP-HIJUTE7\MYSQLDB;Initial Catalog=testDB;Integrated Security=True" cn.Open() cmd.CommandText = "SELECT TABLE_NAME,COLUMN_NAME, DATA_TYPE,COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='" & tableName1 & "' " cmd.Connection = cn dr = cmd.ExecuteReader nbreEnregistrement = 0 Dim tb_table As Table = New Table() tb1.Controls.Add(tb_table) While dr.Read() tableName = dr(0).ToString lblName.Text = tableName1 Dim tr As TableRow = New TableRow() Dim tblCols As Integer = 2 Dim tc As TableCell = New TableCell() dt = dr(2).ToString tablechamp = dr(1).ToString Dim txtBox As TextBox = New TextBox() txtBox.Text = tablechamp txtBox.ReadOnly = "True" txtBox.BorderStyle = "1" txtBox.ID = "champ" & nbreEnregistrement Response.Write(txtBox.ID) ' ajout control au TableCell tc.Controls.Add(txtBox) ' ajout TableCell au TableRow tr.Cells.Add(tc) 'ajout les label au tableau de controls mycontrols 'myControls.Add(txtBox) If dt = "nvarchar" Or dt = "int" Then Dim texttype As New TextBox texttype.ID = "txt" & nbreEnregistrement Response.Write(texttype.ID) texttype.Style("Top") = "25px" texttype.Style("Left") = "100px" 'Add the control to the TableCell tc.Controls.Add(texttype) 'ajout control lel tableau du control ' myControls.Add(texttype) ' Add the TableCell to the TableRow tr.Cells.Add(tc) ElseIf dt = "uniqueidentifier" And dr(3).ToString <> "(newid())" Then 'creation dropdownliste Dim ddlist As New DropDownList() ddlist.ID = "drop" & nbreEnregistrement Response.Write(ddlist.ID) ddlist.DataValueField = dr(1).ToString ' Add the control to the TableCell tc.Controls.Add(ddlist) tr.Cells.Add(tc) ElseIf dt = "bit" Then 'case à cocher Dim checkBox As New CheckBox() checkBox.Checked = True checkBox.ID = "check" & nbreEnregistrement Response.Write(checkBox.ID) ' Add the control to the TableCell tc.Controls.Add(checkBox) ' Add the TableCell to the TableRow tr.Cells.Add(tc) End If ' Add the TableRow to the Table tb_table.Rows.Add(tr) ' End If nbreEnregistrement = nbreEnregistrement + 1 End While cn.Close() Dim btnValid As Button = New Button() btnValid.Text = "Enregistrer" btnValid.Enabled = "True" AddHandler btnValid.Click, AddressOf ValidButton_Clic tb1.Controls.Add(btnValid) End Sub
EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI Merci d'y penser dans tes prochains messages. |
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question