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

addhandler event not firing

here im trying to create imagebuttons dynamically, and on click of button, the delete function should be called.

actually commandargument is not passed into the imgBtn_Click
im not getting any errors
but its not working
plz help
its very urgent


thanx in advance

here is the code....

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class mbrSetClientManufacturer
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

Protected WithEvents ddlProductType As System.Web.UI.WebControls.DropDownList
Protected WithEvents ddlManufacturer As System.Web.UI.WebControls.DropDownList
Protected WithEvents btnAdd As System.Web.UI.WebControls.Button
Protected WithEvents frmSetProductType As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents tblProductTypeNumber As System.Web.UI.WebControls.Table
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents ddlClient As System.Web.UI.WebControls.DropDownList
Protected WithEvents tblClientNumber As System.Web.UI.WebControls.Table
Protected WithEvents frmSetClient As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents imgBtn As System.Web.UI.WebControls.ImageButton
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()

End Sub
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

#End Region


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

btnAdd.Attributes.Add("onclick", "return validate();")
If Not Page.IsPostBack Then

Dim dtManufacturer As New DataTable
Dim dtClient As New DataTable

Dim objClientManufacturer As New ClientProductManufacturerDetails
dtClient = objClientManufacturer.grsClientNamelist(Session("F P_companyId"))
dtManufacturer = objClientManufacturer.grsManufacturerName(Session( "FP_companyId"))

ddlClient.Items.Add(New ListItem("select from..", 0))
ddlManufacturer.Items.Add(New ListItem("select from..", 0))
Dim drClient As DataRow
For Each drClient In dtClient.Rows
ddlClient.Items.Add(New ListItem(drClient("ClientName").ToString, drClient("FP_ClientID").ToString))
Next
Dim drManufacturer As DataRow
For Each drManufacturer In dtManufacturer.Rows
ddlManufacturer.Items.Add(New ListItem(drManufacturer("SupplierName").ToString, drManufacturer("FP_ProductSupplierCompanyID").ToSt ring))
Next

Dim modesave As String
modesave = Request.QueryString.Item("mode")
If (modesave = "frmsav") Then
gentable()
ddlClient.SelectedValue = Request.QueryString.Item("FP_ClientID").ToString
ddlManufacturer.SelectedValue = Request.QueryString.Item("FP_ProductSupplierCompan yID").ToString
modesave = " "
End If

End If

End Sub


Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
If (ddlClient.SelectedIndex <> 0) And (ddlManufacturer.SelectedIndex <> 0) Then
Response.Redirect("mbrSetClientManufacturerEdit.as px?FP_ClientID=" & ddlClient.SelectedItem.Value & "&FP_ProductSupplierCompanyID=" & ddlManufacturer.SelectedItem.Value)
End If
End Sub

Private Sub ddlClient_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlClient.SelectedIndexChanged
gentable()
End Sub

Private Sub ddlManufacturer_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlManufacturer.SelectedIndexChanged
gentable()
End Sub


Private Sub gentable()
Dim dtGenClient As DataTable
Dim objGenClientNumbers As New ClientProductManufacturerDetails
dtGenClient = objGenClientNumbers.GenClientNumbers(Session("FP_C ompanyID"), ddlManufacturer.SelectedItem.Value, ddlClient.SelectedItem.Value)

Dim lit As LiteralControl
Dim cell As TableCell
Dim dr As DataRow

If ((ddlClient.SelectedIndex > 0) And (ddlManufacturer.SelectedIndex > 0)) Then
For Each dr In dtGenClient.Rows
Dim row As New TableRow
tblClientNumber.Rows.Add(row)
lit = New LiteralControl(dr("ClientNumber").ToString)
cell = New TableCell
cell.Controls.Add(lit)
cell.HorizontalAlign = HorizontalAlign.Center
row.Cells.Add(cell)
If (dr("inuse") = 0) Then
buildimagebutton(row, dr("FP_ManufacturerClientNumberID"))
Else
buildimagebutton(row, Nothing)

End If

Next
If dtGenClient.Rows.Count <= 0 Then
Label1.Visible = True
Else
Label1.Visible = False

End If
End If
End Sub

Private Sub buildimagebutton(ByVal row As TableRow, ByVal cid As Integer)
Dim cell As New TableCell
Dim imgBtn As New ImageButton
AddHandler imgBtn.Command, AddressOf imgBtn_Click
If (cid <> Nothing) Then
imgBtn.ImageUrl = "../images/btn_delete.gif"
Else
imgBtn.ImageUrl = "../images/btn_spacer.gif"
End If
imgBtn.CommandArgument = cid

cell.Controls.Add(imgBtn)
cell.HorizontalAlign = HorizontalAlign.Center
cell.VerticalAlign = VerticalAlign.Middle
row.Cells.Add(cell)

End Sub


Sub imgBtn_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Dim objdel As New ClientProductManufacturerDetails
objdel.delManufacturerClientNumber(Session("FP_Com panyID"), e.CommandArgument)

End Sub



End Class
Jun 14 '07 #1
2 1656
kenobewan
4,871 Expert 4TB
Welcome to TSDN. I believe that the sequence of events is a problem. I believe you need to create the image in the onload and dynamically change it later - but the object needs to exist earlier even if visibility is false. I also foresee problems with three of your functions. HTH.
Jun 14 '07 #2
thanx for ur reply kenobewan

i have changed my code and created the imagebutton in the onload. now it works, but the page doen't get refreshed once i click on imagbutton which on click deletes one row in the table.

can u plz tell me how to refresh a page after eventhandling.


Welcome to TSDN. I believe that the sequence of events is a problem. I believe you need to create the image in the onload and dynamically change it later - but the object needs to exist earlier even if visibility is false. I also foresee problems with three of your functions. HTH.
Jun 18 '07 #3

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

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
0
by: Jeffrey A. Voigt | last post by:
Can someone take a quick glace at my code and tell me why my AutoPostBackHandler function does not get fired off at all? What I'm trying to do is get all of the Buttons and DropDownList controls...
1
by: Tee | last post by:
Hi, I have a server control Table with each row will contain a dynamic created ImageButton. And I have a private sub with the proper delegate of an ImageButton click which handle nothing....
4
by: DJ | last post by:
Good morning, Still new at this so please bear with me. I am creating a table dynamically using webcontrols based on the output of a sproc from my database.The table represents test instances...
3
by: Thiago Arrais | last post by:
I am writing a VS .NET Addin and I need to create menu items (CommandBarButtons) at run-time. I can do that but the event handlers do not work. They are registered using AddHandler (wich was...
5
by: eBob.com | last post by:
I've used AddHandler for a UNIQUE control added to a panel and it seemed to work. But now I want to add a bunch of controls to a panel and use only one event handler subroutine. And I am...
2
by: TrtnJohn | last post by:
If you call AddHandler and hook events of one object to a method in a class will the event source object still be available for garbage collection if the original reference is set to Nothing? Or...
12
by: Tom | last post by:
I use dynamically created controls all the time. I.E. I create the control in code then use AddHandler to add the necessary delegates for processing (like Click, etc). Does one have to call...
5
by: Slim | last post by:
i have a simple page, with one button button1. when click it creates a new button button 2 and adds a event handler to it. but when button 2 is clicked nothing happens, why? Partial Class...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.