G
Guest
Hi
I am trying to create a list dynamically as follow
Private conn As New System.Data.SqlClient.SqlConnectio
Private WithEvents htm As System.Web.UI.HtmlControls.HtmlAncho
Protected WithEvents tbl As System.Web.UI.WebControls.Tabl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
'If Not Page.IsPostBack The
GetReports()
'End I
End Su
Private Sub htm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles htm.ServerClic
Response.Write("You clicked on: " & CStr(CType(sender, System.Web.UI.HtmlControls.HtmlAnchor).Name)
End Su
Private Sub GetReports(
Dim cmd As New System.Data.SqlClient.SqlComman
Dim _rdr As System.Data.SqlClient.SqlDataReade
InitializeConnection(
Tr
cmd.CommandText = "GetReports
cmd.CommandType = CommandType.StoredProcedur
cmd.CommandTimeout = 36
cmd.Connection = con
If conn.State = ConnectionState.Open Then conn.Close(
conn.Open(
_rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection
Dim r As TableRow = New TableRo
Dim c As TableCell = New TableCel
Dim btn1 As New System.Web.UI.HtmlControls.HtmlButto
Do While _rdr.Rea
Dim img As New System.Web.UI.WebControls.Imag
Dim htm1 As New System.Web.UI.HtmlControls.HtmlAncho
Controls.Add(htm1
img.ImageUrl = "http://portal/dev/ReportsImages/navlink.gif
htm1.Name = _rdr.Item("DescriptionRefID"
htm1.InnerText = _rdr.Item("Description"
htm1.Attributes.Add("class", "Normal"
htm1.HRef = "WebForm1.aspx
c.Controls.Add(img
c.Controls.Add(New LiteralControl(" ")
c.Controls.Add(htm1
c.Controls.Add(New LiteralControl("<br>")
c.Height = Unit.Pixel(17
r.Cells.Add(c
tbl.Rows.Add(r
AddHandler htm1.ServerClick, AddressOf htm_Clic
Loo
Catch ex As Exceptio
If Not _rdr.IsClosed Then _rdr.Close(
If conn.State = ConnectionState.Open Then conn.Close(
Throw New Exceptio
Finall
If Not _rdr.IsClosed Then _rdr.Close(
If conn.State = ConnectionState.Open Then conn.Close(
End Tr
End Su
'--// Set up the Connectio
Private Sub InitializeConnection(
conn = New System.Data.SqlClient.SqlConnection(strConnect()
End Su
Private Function strConnect() As Strin
Dim m_strConn As System.Strin
m_strConn = System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"
Return m_strCon
End Functio
But whenever I uncomment the IsPostBack in my load event so that GetReport function doesn't get called everytime the page is reloaded it does not capture the click event of my HTMLAnchor click event!
Can you tell me why and how to make this work without having me to call the GetReport every time the page is refreshed
Thanks
Yama
I am trying to create a list dynamically as follow
Private conn As New System.Data.SqlClient.SqlConnectio
Private WithEvents htm As System.Web.UI.HtmlControls.HtmlAncho
Protected WithEvents tbl As System.Web.UI.WebControls.Tabl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
'If Not Page.IsPostBack The
GetReports()
'End I
End Su
Private Sub htm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles htm.ServerClic
Response.Write("You clicked on: " & CStr(CType(sender, System.Web.UI.HtmlControls.HtmlAnchor).Name)
End Su
Private Sub GetReports(
Dim cmd As New System.Data.SqlClient.SqlComman
Dim _rdr As System.Data.SqlClient.SqlDataReade
InitializeConnection(
Tr
cmd.CommandText = "GetReports
cmd.CommandType = CommandType.StoredProcedur
cmd.CommandTimeout = 36
cmd.Connection = con
If conn.State = ConnectionState.Open Then conn.Close(
conn.Open(
_rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection
Dim r As TableRow = New TableRo
Dim c As TableCell = New TableCel
Dim btn1 As New System.Web.UI.HtmlControls.HtmlButto
Do While _rdr.Rea
Dim img As New System.Web.UI.WebControls.Imag
Dim htm1 As New System.Web.UI.HtmlControls.HtmlAncho
Controls.Add(htm1
img.ImageUrl = "http://portal/dev/ReportsImages/navlink.gif
htm1.Name = _rdr.Item("DescriptionRefID"
htm1.InnerText = _rdr.Item("Description"
htm1.Attributes.Add("class", "Normal"
htm1.HRef = "WebForm1.aspx
c.Controls.Add(img
c.Controls.Add(New LiteralControl(" ")
c.Controls.Add(htm1
c.Controls.Add(New LiteralControl("<br>")
c.Height = Unit.Pixel(17
r.Cells.Add(c
tbl.Rows.Add(r
AddHandler htm1.ServerClick, AddressOf htm_Clic
Loo
Catch ex As Exceptio
If Not _rdr.IsClosed Then _rdr.Close(
If conn.State = ConnectionState.Open Then conn.Close(
Throw New Exceptio
Finall
If Not _rdr.IsClosed Then _rdr.Close(
If conn.State = ConnectionState.Open Then conn.Close(
End Tr
End Su
'--// Set up the Connectio
Private Sub InitializeConnection(
conn = New System.Data.SqlClient.SqlConnection(strConnect()
End Su
Private Function strConnect() As Strin
Dim m_strConn As System.Strin
m_strConn = System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"
Return m_strCon
End Functio
But whenever I uncomment the IsPostBack in my load event so that GetReport function doesn't get called everytime the page is reloaded it does not capture the click event of my HTMLAnchor click event!
Can you tell me why and how to make this work without having me to call the GetReport every time the page is refreshed
Thanks
Yama