473,413 Members | 1,718 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,413 software developers and data experts.

Handling Dynamic Image buttons

hi...im working on asp.net with VB
i have created a database which hav fields id,name,image path
in web form i hav written code for creation of image buttons dynamically
i hav connected the form to DB and got the table into DataSet

and also i hav placed one panel which contains image and label controls

for dynamic image buttons i hav given the image URL from table only. and i hav written addHandler method to hanling events

But for every button it handling one event only....

when i click the image button which r developed dynamically.....the panel shld show the details of that imagebutton.

---------------------------------------------------------------------------

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.Control
.
Partial Class Default2
Inherits System.Web.UI.Page

Dim con As New SqlConnection
Dim da As SqlClient.SqlDataAdapter
Dim strSQL As String
Dim ds As New DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con = New SqlConnection("Data Source=SYSTEM23\SQLEXPRESS;Initial Catalog=epo;Integrated Security=True")
strSQL = "select * from details"
da = New SqlClient.SqlDataAdapter(strSQL, con)
da.Fill(ds, "details")
Dim i As Int16
Dim j As Int16
Dim counter As Int16 = 0

i = ds.Tables("details").Rows.Count.ToString

For j = 0 To i - 1

Dim img As New ImageButton
img.ID = "imageButton" & j


PlaceHolder1.Controls.Add(img)
img.Visible = True
img.ImageUrl = ds.Tables("details").Rows(j)(2)
img.Width = 200
img.Height = 200
AddHandler img.Command, AddressOf method1

'-- Add a pair of blank spaces

Dim MySpace As New Literal
MySpace.Text = "      "
PlaceHolder1.Controls.Add(MySpace)

'-- Add a line break
Counter += 1
If counter Mod 4 = 0 Then
Dim MyBreak As New Literal
MyBreak.Text = "<br/>"
PlaceHolder1.Controls.Add(MyBreak)

End If

Next


End Sub
Private Sub method1(ByVal Src As Object, ByVal Args As CommandEventArgs)

Panel1.Visible = True

End Sub
Jun 25 '07 #1
4 2022
dip_developer
648 Expert 512MB
hi...im working on asp.net with VB
i have created a database which hav fields id,name,image path
in web form i hav written code for creation of image buttons dynamically
i hav connected the form to DB and got the table into DataSet

and also i hav placed one panel which contains image and label controls

for dynamic image buttons i hav given the image URL from table only. and i hav written addHandler method to hanling events

But for every button it handling one event only....

when i click the image button which r developed dynamically.....the panel shld show the details of that imagebutton.

---------------------------------------------------------------------------

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.Control
.
Partial Class Default2
Inherits System.Web.UI.Page

Dim con As New SqlConnection
Dim da As SqlClient.SqlDataAdapter
Dim strSQL As String
Dim ds As New DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con = New SqlConnection("Data Source=SYSTEM23\SQLEXPRESS;Initial Catalog=epo;Integrated Security=True")
strSQL = "select * from details"
da = New SqlClient.SqlDataAdapter(strSQL, con)
da.Fill(ds, "details")
Dim i As Int16
Dim j As Int16
Dim counter As Int16 = 0

i = ds.Tables("details").Rows.Count.ToString

For j = 0 To i - 1

Dim img As New ImageButton
img.ID = "imageButton" & j


PlaceHolder1.Controls.Add(img)
img.Visible = True
img.ImageUrl = ds.Tables("details").Rows(j)(2)
img.Width = 200
img.Height = 200
AddHandler img.Command, AddressOf method1

'-- Add a pair of blank spaces

Dim MySpace As New Literal
MySpace.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
PlaceHolder1.Controls.Add(MySpace)

'-- Add a line break
Counter += 1
If counter Mod 4 = 0 Then
Dim MyBreak As New Literal
MyBreak.Text = "<br/>"
PlaceHolder1.Controls.Add(MyBreak)

End If

Next


End Sub
Private Sub method1(ByVal Src As Object, ByVal Args As CommandEventArgs)

Panel1.Visible = True

End Sub
So whats the problem?????....You have created one Eventhandler for every button.....this event will cause method1 to be executed in every button's click....you can have the button's id ,which causing the event to fire,inside method1 and do the needful.
Jun 25 '07 #2
kenobewan
4,871 Expert 4TB
Your eventhandler can call one function which in turn call another.
Jun 25 '07 #3
ACTUALLY I WANT TO GET THE DETAILS OF PRODUCT FROM DataSet TO THE PANEL.......THIS DETAILS DEPENDS ON THE WHICH IMAGE BUTTON WE HAV CLICKED ........
SAMPLE WEB PAGE:

http://search.live.com/images/results.aspx?q=nokia&FORM=QBIR

c the above link....u can get some idea

if i run my prog i will get the page like above

if i click on any image button the selected image details should be come to panel.....

Plz help me in this

if u give mail address...i will send this project also
Jun 26 '07 #4
Plzz help me in this..........
Jun 28 '07 #5

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

Similar topics

3
by: JOSEPHINE ALVAREZ | last post by:
I have this code that I want to use to do a rollover. However, because the company I am doing it for is continually changing the text, I want to be able to use dynamic text to change the text on...
8
by: Tim Geiges | last post by:
Since I am being challenged with learning c# I figured I could pass some of the pain on to you guys :-) I have another question(this one is important for me to fix before I can get my app to Beta)...
1
by: | last post by:
Hello Guys, I am rendering the server controls dynamically using XSLT but having tough time positioning them on the web form the place where I want them to be. To be precise, I have two image...
6
by: Steve Caliendo | last post by:
Hi, I'm creating 5 ImageButton controls in the panel control, and I have a unique ID specified for each one. When I click on any one of them, the Page_Load executes (Of course), but how do I...
0
by: Georg Fleischer | last post by:
Hello, I have the following problem. I need to insert my global image-path to an icon the EditText Property of my <asp:DataGrid> control. <asp:EditCommandColumn ButtonType="LinkButton"...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
3
by: topmind | last post by:
I am generally new to dot.net, coming from "scriptish" web languages such as ColdFusion and Php. I have a few questions if you don't mind. First, how does one go about inserting dynamic SQL...
2
by: WolfyUK | last post by:
Hello, I have a standard asp:DataGrid called CasesGrid that I wish to write my own paging controls for. The aim is to get something like the following rendered to screen: << First < Previous...
3
by: Mark | last post by:
Assume you want to dynamically add one to many link button controls to a web page dynamically at run time. Each link button needs to post back and execute code. As the link buttons are created at...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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:
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
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.