Thanks Karl,
Yes I m using VS.Net
In fact, I ve used a Panel control and I ve added the Table like this
Panel1.Controls.Add(tableau)
So, I will try yours..
However, I still have a little problem.
here's my code.
I would like to use the Page.Ispostback to avoid to reload the database and
I would like to update it when I click on the button.
If you have time to look at the code and tell me where I can add the
Ispostback command.
When the button is pressed and the database is update I would like to change
the button text to "Updated".
I think I will be able to change it to Update when one textbox will be
modified.
As I said, I m from ASP ... so....
Here's the code..
Imports System.Configuration
Imports System.Data.SqlClient
Public Class A_QUESTIONS
Inherits System.Web.UI.Page
Dim Ds As New DataSet("MonDS")
Dim cn As New
SqlConnection(ConfigurationSettings.AppSettings.Item("dbData"))
Protected WithEvents Table As System.Web.UI.WebControls.Table
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents Bouton As System.Web.UI.WebControls.Button
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Dim Table1 As Table
Dim Langue As String
Dim tables As New Hashtable(15)
#Region " Code généré par le Concepteur Web Form "
'Cet appel est requis par le Concepteur Web Form.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
'REMARQUE : la déclaration d'espace réservé suivante est requise par le
Concepteur Web Form.
'Ne pas supprimer ou déplacer.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN : cet appel de méthode est requis par le Concepteur Web
Form
'Ne le modifiez pas en utilisant l'éditeur de code.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Langue = "FR"
Dim Pays, Chapitre, Schapitre As Integer
'Pays = Request.QueryString("PAYS")
Pays = 1
Chapitre = Request.QueryString("IDC")
If Request.QueryString("IDS") = "" Then
Schapitre = 0
Else
Schapitre = Request.QueryString("IDS")
End If
Ds.Tables.Add("QUESTIONS")
Dim daQUESTIONS As New SqlDataAdapter
daQUESTIONS.SelectCommand = SQL_LISTE_QUESTIONS(Langue, Pays,
Chapitre, Schapitre)
daQUESTIONS.Fill(Ds.Tables("QUESTIONS"))
Dim paragraphe As String = ""
Dim tableau As New Table
Dim Ligne As New TableRow
Dim cell1 As New TableCell
Dim cell2 As New TableCell
Dim cell3 As New TableCell
Dim row As DataRow
Dim i As Integer
Dim CPTAN As Integer = 3
For i = 1993 To 2008
CPTAN += 1
tableau = New Table
tableau.ID = "Q" + i.ToString
tableau.Visible = False
For Each row In Ds.Tables("QUESTIONS").Rows
If paragraphe <> row("paragraphe") Then
Ligne = New TableRow
cell1 = New TableCell
cell1.ColumnSpan = 3
cell1.Text = row("Paragraphe")
paragraphe = row("paragraphe")
Ligne.Cells.Add(cell1)
tableau.Rows.Add(Ligne)
End If
Ligne = New TableRow
cell1 = New TableCell
cell2 = New TableCell
cell3 = New TableCell
If row("Question") = "[TEXT]" Then
cell1.Text = "<INPUT TYPE=TEXT NAME=T_" &
row("idquestion") & "_" & i & " VALUE=""" & row(16 + CPTAN) & """>"
Else
cell1.Text = row("Question")
End If
cell2.Text = "<INPUT TYPE=TEXT NAME=" & row("idquestion") &
"_" & i & " VALUE=""" & row(16 + CPTAN) & """ onBlur=""TypeChamps(this,'" &
Trim(row("TypeTest")) & "');"">"
cell3.Text = "<INPUT TYPE=TEXT NAME=S" & row("idquestion") &
"_" & i & " VALUE=""" & row(16 + CPTAN) & """>"
cell1.Width = Unit.Point(254)
cell2.Width = Unit.Point(100)
cell3.Width = Unit.Point(110)
Ligne.Cells.Add(cell1)
Ligne.Cells.Add(cell2)
Ligne.Cells.Add(cell3)
tableau.Rows.Add(Ligne)
Next
Ligne = New TableRow
cell1 = New TableCell
cell1.ColumnSpan = 3
Dim button1 As New Button
button1.CausesValidation = False
button1.Text = "Mise à Jour"
button1.ID = "B" + i.ToString
cell1.Controls.Add(button1)
Ligne.Cells.Add(cell1)
tableau.Rows.Add(Ligne)
tableau.Visible = False
Panel1.Controls.Add(tableau)
tables.Add(i, tableau)
Next
Table1 = CType(tables(1999), Table)
Table1.Visible = True
End Sub
Private Function SQL_LISTE_QUESTIONS(ByVal Langue As String, ByVal Pays
As Integer, ByVal Chapitre As Integer, ByVal Schapitre As Integer) As
SqlCommand
Dim cmd As New SqlCommand("A_LISTE_QUESTIONS", cn)
cmd.CommandType = CommandType.StoredProcedure
Dim pc As SqlParameterCollection = cmd.Parameters
pc.Add("@langue", SqlDbType.VarChar, 2)
pc.Add("@Pays", SqlDbType.Int, 4)
pc.Add("@Chapitre", SqlDbType.Int, 4)
pc.Add("@Schapitre", SqlDbType.Int, 4)
pc("@langue").Value = Langue
pc("@pays").Value = Pays
pc("@Chapitre").Value = Chapitre
pc("@Schapitre").Value = Schapitre
Return cmd
End Function
Private Sub Bouton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Bouton.Click
sender.text = "OK"
End Sub