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.Sql Client
Imports System.Web.UI.C ontrol
.
Partial Class Default2
Inherits System.Web.UI.P age
Dim con As New SqlConnection
Dim da As SqlClient.SqlDa taAdapter
Dim strSQL As String
Dim ds As New DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
con = New SqlConnection(" Data Source=SYSTEM23 \SQLEXPRESS;Ini tial Catalog=epo;Int egrated Security=True")
strSQL = "select * from details"
da = New SqlClient.SqlDa taAdapter(strSQ L, con)
da.Fill(ds, "details")
Dim i As Int16
Dim j As Int16
Dim counter As Int16 = 0
i = ds.Tables("deta ils").Rows.Coun t.ToString
For j = 0 To i - 1
Dim img As New ImageButton
img.ID = "imageButto n" & j
PlaceHolder1.Co ntrols.Add(img)
img.Visible = True
img.ImageUrl = ds.Tables("deta ils").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 = " &n bsp;   ; "
PlaceHolder1.Co ntrols.Add(MySp ace)
'-- Add a line break
Counter += 1
If counter Mod 4 = 0 Then
Dim MyBreak As New Literal
MyBreak.Text = "<br/>"
PlaceHolder1.Co ntrols.Add(MyBr eak)
End If
Next
End Sub
Private Sub method1(ByVal Src As Object, ByVal Args As CommandEventArg s)
Panel1.Visible = True
End Sub
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.Sql Client
Imports System.Web.UI.C ontrol
.
Partial Class Default2
Inherits System.Web.UI.P age
Dim con As New SqlConnection
Dim da As SqlClient.SqlDa taAdapter
Dim strSQL As String
Dim ds As New DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
con = New SqlConnection(" Data Source=SYSTEM23 \SQLEXPRESS;Ini tial Catalog=epo;Int egrated Security=True")
strSQL = "select * from details"
da = New SqlClient.SqlDa taAdapter(strSQ L, con)
da.Fill(ds, "details")
Dim i As Int16
Dim j As Int16
Dim counter As Int16 = 0
i = ds.Tables("deta ils").Rows.Coun t.ToString
For j = 0 To i - 1
Dim img As New ImageButton
img.ID = "imageButto n" & j
PlaceHolder1.Co ntrols.Add(img)
img.Visible = True
img.ImageUrl = ds.Tables("deta ils").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 = " &n bsp;   ; "
PlaceHolder1.Co ntrols.Add(MySp ace)
'-- Add a line break
Counter += 1
If counter Mod 4 = 0 Then
Dim MyBreak As New Literal
MyBreak.Text = "<br/>"
PlaceHolder1.Co ntrols.Add(MyBr eak)
End If
Next
End Sub
Private Sub method1(ByVal Src As Object, ByVal Args As CommandEventArg s)
Panel1.Visible = True
End Sub
Comment