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