473,414 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Dynamic Table Question

Hi,

I use this bit of code to generate dynamic tables in the page load section
....
Dim ntable as New Table
For i = 1993 To 2008
ntable = New Table
ntable.ID = "Q" + i.ToString
....
....
Next

How to use the properties of each table ?
I would like to set visible and not visible some of them using their ID.

Stan
Nov 18 '05 #1
7 1415
Stan, I'd add the tables to a hashtable so that you can access them back
that way:

Dim tables as HashTable(15)
for i = 1993 to 2008
dim table as new Table()
...
Controls.Add(table)
tables.Add(i, table)
next

you can then access the table by the year:

dim table as Table = ctype(tables(1999), Table)
table.visible = false

Karl
"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:OF**************@TK2MSFTNGP09.phx.gbl...
Hi,

I use this bit of code to generate dynamic tables in the page load section
...
Dim ntable as New Table
For i = 1993 To 2008
ntable = New Table
ntable.ID = "Q" + i.ToString
....
....
Next

How to use the properties of each table ?
I would like to set visible and not visible some of them using their ID.

Stan

Nov 18 '05 #2
Hi Karl
It seems the Dim tables as HashTable(15) is not correct..
:(
Stan

"Karl" <none> a écrit dans le message de news:
#m**************@TK2MSFTNGP10.phx.gbl...
Stan, I'd add the tables to a hashtable so that you can access them back
that way:

Dim tables as HashTable(15)
for i = 1993 to 2008
dim table as new Table()
...
Controls.Add(table)
tables.Add(i, table)
next

you can then access the table by the year:

dim table as Table = ctype(tables(1999), Table)
table.visible = false

Karl
"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:OF**************@TK2MSFTNGP09.phx.gbl...
Hi,

I use this bit of code to generate dynamic tables in the page load section ...
Dim ntable as New Table
For i = 1993 To 2008
ntable = New Table
ntable.ID = "Q" + i.ToString
....
....
Next

How to use the properties of each table ?
I would like to set visible and not visible some of them using their ID.

Stan


Nov 18 '05 #3
Maybe I have to reconsider my code.

Here s what I want to do (I works fine with ASP and I m trying to do it with
asp.net)

I need to load 16 tables, and hide 15 of them.
I have a another table where I display the years between 1993 to 2008
When I choose one year, I would like to hide all the table and just display
the table regarding the year.
Within asp, I m using Span and a javascript for hiding/showing the right
table.
Any help ?

Of course all the tables are dynamic and their content come from a database.
I don't have problems with the ado.net part..

Stan


"Ryan Riddell" <Ry*********@discussions.microsoft.com> a écrit dans le
message de news: 88**********************************@microsoft.com...
Can you do this while inside the for loop?

Otherwise you can do ((Table)container.FindControl("Q" + i)).Visible =
false;. Where container is the object you added the table controls to. But I'm not sure if the container controls will be available immediately after
adding them.

"Stan Sainte-Rose" wrote:
Hi,

I use this bit of code to generate dynamic tables in the page load section ....
Dim ntable as New Table
For i = 1993 To 2008
ntable = New Table
ntable.ID = "Q" + i.ToString
....
....
Next

How to use the properties of each table ?
I would like to set visible and not visible some of them using their ID.

Stan

Nov 18 '05 #4
Oopps..forgot the new
Try:
Dim tables as new Hashtable(15)

or, if you don't have System.Collections imported, try:
Dim tables As New System.Collections.Hashtable(15)

What ryan says about using FindControl will also work, but you should get
better performance this way, and you'll need to do less error checking.

Karl

"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Karl
It seems the Dim tables as HashTable(15) is not correct..
:(
Stan

"Karl" <none> a écrit dans le message de news:
#m**************@TK2MSFTNGP10.phx.gbl...
Stan, I'd add the tables to a hashtable so that you can access them back
that way:

Dim tables as HashTable(15)
for i = 1993 to 2008
dim table as new Table()
...
Controls.Add(table)
tables.Add(i, table)
next

you can then access the table by the year:

dim table as Table = ctype(tables(1999), Table)
table.visible = false

Karl
"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:OF**************@TK2MSFTNGP09.phx.gbl...
Hi,

I use this bit of code to generate dynamic tables in the page load section ...
Dim ntable as New Table
For i = 1993 To 2008
ntable = New Table
ntable.ID = "Q" + i.ToString
....
....
Next

How to use the properties of each table ?
I would like to set visible and not visible some of them using their ID.
Stan



Nov 18 '05 #5
Hi again

Stupid question...
Your procedure works fine..

But I have a problem..
When I look at the html source from the browser, the table is out the <Form>
tag.
How can I add the table between <Form> and </Form> knowing that my table has
input textbox and a submit button

Or, is there an elegant method to do it ?

Stan

"Karl" <none> a écrit dans le message de news:
#n*************@TK2MSFTNGP09.phx.gbl...
Oopps..forgot the new
Try:
Dim tables as new Hashtable(15)

or, if you don't have System.Collections imported, try:
Dim tables As New System.Collections.Hashtable(15)

What ryan says about using FindControl will also work, but you should get
better performance this way, and you'll need to do less error checking.

Karl

"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Karl
It seems the Dim tables as HashTable(15) is not correct..
:(
Stan

"Karl" <none> a écrit dans le message de news:
#m**************@TK2MSFTNGP10.phx.gbl...
Stan, I'd add the tables to a hashtable so that you can access them back that way:

Dim tables as HashTable(15)
for i = 1993 to 2008
dim table as new Table()
...
Controls.Add(table)
tables.Add(i, table)
next

you can then access the table by the year:

dim table as Table = ctype(tables(1999), Table)
table.visible = false

Karl
"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:OF**************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I use this bit of code to generate dynamic tables in the page load

section
> ...
> Dim ntable as New Table
> For i = 1993 To 2008
> ntable = New Table
> ntable.ID = "Q" + i.ToString
> ....
> ....
> Next
>
> How to use the properties of each table ?
> I would like to set visible and not visible some of them using their ID. >
> Stan
>
>



Nov 18 '05 #6
When you did Controls.Add(table), you were accessing the Page's Control
property and adding the table to it Instead, you want to add the tables to
the Controls() property of the form, or a placeholder inside the form.

Not sure if you are using vs.net or not, but you should be able to to
Form1.Controls.Add(table) where Form1 is the ID of the form.

Karl

"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi again

Stupid question...
Your procedure works fine..

But I have a problem..
When I look at the html source from the browser, the table is out the <Form> tag.
How can I add the table between <Form> and </Form> knowing that my table has input textbox and a submit button

Or, is there an elegant method to do it ?

Stan

"Karl" <none> a écrit dans le message de news:
#n*************@TK2MSFTNGP09.phx.gbl...
Oopps..forgot the new
Try:
Dim tables as new Hashtable(15)

or, if you don't have System.Collections imported, try:
Dim tables As New System.Collections.Hashtable(15)

What ryan says about using FindControl will also work, but you should get
better performance this way, and you'll need to do less error checking.

Karl

"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Karl
It seems the Dim tables as HashTable(15) is not correct..
:(
Stan

"Karl" <none> a écrit dans le message de news:
#m**************@TK2MSFTNGP10.phx.gbl...
> Stan, I'd add the tables to a hashtable so that you can access them back > that way:
>
> Dim tables as HashTable(15)
> for i = 1993 to 2008
> dim table as new Table()
> ...
> Controls.Add(table)
> tables.Add(i, table)
> next
>
> you can then access the table by the year:
>
> dim table as Table = ctype(tables(1999), Table)
> table.visible = false
>
> Karl
>
>
> "Stan Sainte-Rose" <st**@cyber972.com> wrote in message
> news:OF**************@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I use this bit of code to generate dynamic tables in the page load
section
> > ...
> > Dim ntable as New Table
> > For i = 1993 To 2008
> > ntable = New Table
> > ntable.ID = "Q" + i.ToString
> > ....
> > ....
> > Next
> >
> > How to use the properties of each table ?
> > I would like to set visible and not visible some of them using

their ID.
> >
> > Stan
> >
> >
>
>



Nov 18 '05 #7
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.It em("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
Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: yzarc | last post by:
I'm working with a DB design that seems to me to be rather complex. This is a very slimmed down version of what I'm doing, but I believe it is enough to get my question resolved. Here is my...
2
by: klh | last post by:
We use DB2 Connect v 7.2 FP7 in Windows NT hitting a OS/390 DB2 v7.1 database. We have a Websphere (java) application that issues dynamic SQL. Most of the time when we issue dynamic SQL SELECT...
14
by: Ina Schmitz | last post by:
Hello, I would like to get the logical and physical reads for every sql statement executed. Thatfore, I used the command "db2 get snapshot for dynamic sql on <mydatabase>". There, I could see...
3
by: CAD Fiend | last post by:
Hello, Well, after an initial review of my database by my client, they have completely changed their minds about how they want their form. As a result, I'm having to re-think the whole process....
3
by: Tyler Carver | last post by:
I am trying to use some dynamic controls that are built and then added to tables. The problem that I am having is the timing of when I can populate the controls and have the state remain after a...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
6
by: =?ISO-8859-1?Q?Tim_B=FCthe?= | last post by:
Hi, we are building a Java webapplication using JSF, running on websphere, querying a DB2 9 on Suse Enterprise 10. The app uses JDBC and PreparedStatements only (aka dynamic SQL). Every night,...
12
by: ive1122 | last post by:
Hi guys, I am looking into create a dynamic survey as posted in Get User Input From Dynamic Controls but with some different environment Below is what i am trying to do: First when the user...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.