473,407 Members | 2,676 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,407 software developers and data experts.

Re-creating controls

gchq
96
Hi there

I've developed a page that creates up to 25 ImageButtons using controls.add, criterea fed from a Database - if the records exceed 25 it creates a button to load the next batch of 25 (essentially by recording a page number in a text box..

The first part of the this runs fine - the ImageButtons are created and I can run the code I want to by clicking them - problem is when is gets to page 2 - it loads the next batch of 25 and retains the old batch! They are visible until a postback is caused and then the old 25 vanish ...

Any ideas?

Here is the much messed around sub...

Expand|Select|Wrap|Line Numbers
  1. Private Sub FillButtons()
  2.  
  3.         Dim i As Integer
  4.         Dim vTop As Integer = 90
  5.         Dim iStart As Integer
  6.         Dim iEnd As Integer
  7.  
  8.         'Determine how many records there are..
  9.         strSQL = "SELECT MAX(ImageView_ID) FROM ImageView"
  10.         cmd = New OdbcCommand(strSQL, conn)
  11.         Dim vRecords As Integer
  12.         conn.Open()
  13.         vRecords = cmd.ExecuteScalar
  14.         conn.Close()
  15.         cmd.Dispose()
  16.  
  17.         Dim vPageNo As Integer = PageNo.Text
  18.         If vPageNo = 1 Then
  19.             If vRecords < 26 Then
  20.                 iStart = 1
  21.                 iEnd = vRecords
  22.             Else
  23.                 iStart = 1
  24.                 iEnd = 25
  25.                 Button1.Visible = True
  26.                 Button2.Visible = False
  27.             End If ' End records if
  28.         ElseIf vPageNo = 2 Then
  29.             If vRecords < 51 Then
  30.                 iStart = 26
  31.                 iEnd = vRecords
  32.                 Button1.Visible = False
  33.                 Button2.Visible = True
  34.             Else
  35.                 iStart = 26
  36.                 iEnd = 50
  37.                 Button1.Visible = True
  38.                 Button2.Visible = True
  39.             End If 'end records if - next ElseIf after this
  40.         End If 'End page number if
  41.         Dim vImageButton As ImageButton
  42.  
  43.         For i = iStart To iEnd
  44.             Dim vFile As String
  45.             If i < 10 Then
  46.                 vFile = "0" & i
  47.             Else
  48.                 vFile = i
  49.             End If
  50.             vImageButton = New ImageButton()
  51.  
  52.             vImageButton.ID = "ImageButton" & i
  53.             ' vImageButton.Style("Position") = "Absolute"
  54.             'vImageButton.Style("Top") = vTop & "px"
  55.             'vImageButton.Style("Left") = "30px"
  56.             vImageButton.Width = 80
  57.             'vImageButton.ImageUrl = "Images/" & vFile & ".jpg"
  58.             AddHandler vImageButton.Click, AddressOf ButtonClick
  59.             Panel1.Controls.Add(vImageButton)
  60.  
  61.  
  62.             vTop = vTop + 102
  63.         Next
  64.  
Jan 16 '08 #1
0 582

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with...
10
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
8
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
1
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id ...
3
by: presspley | last post by:
I have bought the book on advanced dreamweaver and PHP recently. I have installed MySQL and PHP server but am getting an error on the $GET statement show below. It says there is a problem with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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
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...
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...

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.