473,804 Members | 3,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1440
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(ta ble)
tables.Add(i, table)
next

you can then access the table by the year:

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

Karl
"Stan Sainte-Rose" <st**@cyber972. com> wrote in message
news:OF******** ******@TK2MSFTN GP09.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(ta ble)
tables.Add(i, table)
next

you can then access the table by the year:

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

Karl
"Stan Sainte-Rose" <st**@cyber972. com> wrote in message
news:OF******** ******@TK2MSFTN GP09.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*********@di scussions.micro soft.com> a écrit dans le
message de news: 88************* *************** **...icrosof t.com...
Can you do this while inside the for loop?

Otherwise you can do ((Table)contain er.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.Collecti ons imported, try:
Dim tables As New System.Collecti ons.Hashtable(1 5)

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******** ********@TK2MSF TNGP09.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(ta ble)
tables.Add(i, table)
next

you can then access the table by the year:

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

Karl
"Stan Sainte-Rose" <st**@cyber972. com> wrote in message
news:OF******** ******@TK2MSFTN GP09.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.p hx.gbl...
Oopps..forgot the new
Try:
Dim tables as new Hashtable(15)

or, if you don't have System.Collecti ons imported, try:
Dim tables As New System.Collecti ons.Hashtable(1 5)

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******** ********@TK2MSF TNGP09.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(ta ble)
tables.Add(i, table)
next

you can then access the table by the year:

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

Karl
"Stan Sainte-Rose" <st**@cyber972. com> wrote in message
news:OF******** ******@TK2MSFTN GP09.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(ta ble), 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******** ********@TK2MSF TNGP09.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.p hx.gbl...
Oopps..forgot the new
Try:
Dim tables as new Hashtable(15)

or, if you don't have System.Collecti ons imported, try:
Dim tables As New System.Collecti ons.Hashtable(1 5)

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******** ********@TK2MSF TNGP09.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(ta ble)
> tables.Add(i, table)
> next
>
> you can then access the table by the year:
>
> dim table as Table = ctype(tables(19 99), Table)
> table.visible = false
>
> Karl
>
>
> "Stan Sainte-Rose" <st**@cyber972. com> wrote in message
> news:OF******** ******@TK2MSFTN GP09.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.Configur ation
Imports System.Data.Sql Client
Public Class A_QUESTIONS
Inherits System.Web.UI.P age
Dim Ds As New DataSet("MonDS" )
Dim cn As New
SqlConnection(C onfigurationSet tings.AppSettin gs.Item("dbData "))

Protected WithEvents Table As System.Web.UI.W ebControls.Tabl e
Protected WithEvents Panel1 As System.Web.UI.W ebControls.Pane l
Protected WithEvents Bouton As System.Web.UI.W ebControls.Butt on
Protected WithEvents Button1 As System.Web.UI.W ebControls.Butt on
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.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

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 designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) 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.
InitializeCompo nent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Langue = "FR"
Dim Pays, Chapitre, Schapitre As Integer
'Pays = Request.QuerySt ring("PAYS")
Pays = 1
Chapitre = Request.QuerySt ring("IDC")
If Request.QuerySt ring("IDS") = "" Then
Schapitre = 0
Else
Schapitre = Request.QuerySt ring("IDS")
End If
Ds.Tables.Add(" QUESTIONS")
Dim daQUESTIONS As New SqlDataAdapter
daQUESTIONS.Sel ectCommand = SQL_LISTE_QUEST IONS(Langue, Pays,
Chapitre, Schapitre)
daQUESTIONS.Fil l(Ds.Tables("QU ESTIONS"))

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("QUES TIONS").Rows
If paragraphe <> row("paragraphe ") Then
Ligne = New TableRow
cell1 = New TableCell
cell1.ColumnSpa n = 3
cell1.Text = row("Paragraphe ")
paragraphe = row("paragraphe ")
Ligne.Cells.Add (cell1)
tableau.Rows.Ad d(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=""TypeCh amps(this,'" &
Trim(row("TypeT est")) & "');"">"
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.Ad d(Ligne)
Next
Ligne = New TableRow
cell1 = New TableCell
cell1.ColumnSpa n = 3
Dim button1 As New Button
button1.CausesV alidation = False
button1.Text = "Mise à Jour"

button1.ID = "B" + i.ToString
cell1.Controls. Add(button1)
Ligne.Cells.Add (cell1)
tableau.Rows.Ad d(Ligne)
tableau.Visible = False
Panel1.Controls .Add(tableau)
tables.Add(i, tableau)
Next
Table1 = CType(tables(19 99), Table)
Table1.Visible = True
End Sub
Private Function SQL_LISTE_QUEST IONS(ByVal Langue As String, ByVal Pays
As Integer, ByVal Chapitre As Integer, ByVal Schapitre As Integer) As
SqlCommand
Dim cmd As New SqlCommand("A_L ISTE_QUESTIONS" , cn)
cmd.CommandType = CommandType.Sto redProcedure
Dim pc As SqlParameterCol lection = cmd.Parameters
pc.Add("@langue ", SqlDbType.VarCh ar, 2)
pc.Add("@Pays", SqlDbType.Int, 4)
pc.Add("@Chapit re", SqlDbType.Int, 4)
pc.Add("@Schapi tre", SqlDbType.Int, 4)
pc("@langue").V alue = Langue
pc("@pays").Val ue = Pays
pc("@Chapitre") .Value = Chapitre
pc("@Schapitre" ).Value = Schapitre
Return cmd
End Function

Private Sub Bouton_Click(By Val sender As Object, ByVal e As
System.EventArg s) 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
4605
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 layout. These 4 tables are used to generate a questionaire. Survey OrderID
2
8856
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 statements, like through a DB2 command window, the command will be processed using a package like SQLLF000 which uses an isolation level of Cursor Stability. However sometimes in the Websphere application when a dynamic SELECT statement is issued...
14
14873
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 the logical and physical reads from bufferpool for every statement monitored. Am I right? But now, I would like to read these results out of a table so that I could process them automatically. In which table(s) are the results of snapshot for...
3
2944
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. My Current Form (6 tabs): - Owner, Property, Title, Docs, Queries, & Reports - User is able to see (while navigating through the tabs) above in the form : Owner Name, Address, Parcel, and SSN
3
1813
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 postback. The main question would be this: Why does this work for maintaining state after a postback for dynamic controls: myText = new Label(); myText.ID = "myText";
7
3393
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 either AND or OR but never mixed together. We can use Northwind database for my question, it is very similar to the structure of the problem on the database I am working on. IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL DROP TABLE REPORT_SELECTION
0
5295
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 the days in the week with dates and textboxes to fill in some data. row 1: question
9
2988
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 got the core of the javascript from here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm I noticed in the demo that sometimes the content takes a long
6
7975
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, there is a ETL which deletes most of the data in the database and fills it all new. We observed very bad performance for some statements that ran for minutes (The queried table is about 100,000 records and the result is about 500 rows)....
12
24818
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 click the button, it will populate a dynamic table with radio button for the survey questionnaire However, i was unable to get its value (for score calculation) after clicking the submit button Beside i am using an ajax extension (updatePanel) for the...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9569
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6844
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.