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.Sql Client
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Public Class mbrSetClientMan ufacturer
Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
Protected WithEvents ddlProductType As System.Web.UI.W ebControls.Drop DownList
Protected WithEvents ddlManufacturer As System.Web.UI.W ebControls.Drop DownList
Protected WithEvents btnAdd As System.Web.UI.W ebControls.Butt on
Protected WithEvents frmSetProductTy pe As System.Web.UI.H tmlControls.Htm lForm
Protected WithEvents tblProductTypeN umber As System.Web.UI.W ebControls.Tabl e
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected WithEvents ddlClient As System.Web.UI.W ebControls.Drop DownList
Protected WithEvents tblClientNumber As System.Web.UI.W ebControls.Tabl e
Protected WithEvents frmSetClient As System.Web.UI.H tmlControls.Htm lForm
Protected WithEvents imgBtn As System.Web.UI.W ebControls.Imag eButton
Protected WithEvents TextBox1 As System.Web.UI.W ebControls.Text Box
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
btnAdd.Attribut es.Add("onclick ", "return validate();")
If Not Page.IsPostBack Then
Dim dtManufacturer As New DataTable
Dim dtClient As New DataTable
Dim objClientManufa cturer As New ClientProductMa nufacturerDetai ls
dtClient = objClientManufa cturer.grsClien tNamelist(Sessi on("FP_companyI d"))
dtManufacturer = objClientManufa cturer.grsManuf acturerName(Ses sion("FP_compan yId"))
ddlClient.Items .Add(New ListItem("selec t from..", 0))
ddlManufacturer .Items.Add(New ListItem("selec t from..", 0))
Dim drClient As DataRow
For Each drClient In dtClient.Rows
ddlClient.Items .Add(New ListItem(drClie nt("ClientName" ).ToString, drClient("FP_Cl ientID").ToStri ng))
Next
Dim drManufacturer As DataRow
For Each drManufacturer In dtManufacturer. Rows
ddlManufacturer .Items.Add(New ListItem(drManu facturer("Suppl ierName").ToStr ing, drManufacturer( "FP_ProductSupp lierCompanyID") .ToString))
Next
Dim modesave As String
modesave = Request.QuerySt ring.Item("mode ")
If (modesave = "frmsav") Then
gentable()
ddlClient.Selec tedValue = Request.QuerySt ring.Item("FP_C lientID").ToStr ing
ddlManufacturer .SelectedValue = Request.QuerySt ring.Item("FP_P roductSupplierC ompanyID").ToSt ring
modesave = " "
End If
End If
End Sub
Private Sub btnAdd_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles btnAdd.Click
If (ddlClient.Sele ctedIndex <> 0) And (ddlManufacture r.SelectedIndex <> 0) Then
Response.Redire ct("mbrSetClien tManufacturerEd it.aspx?FP_Clie ntID=" & ddlClient.Selec tedItem.Value & "&FP_ProductSup plierCompanyID= " & ddlManufacturer .SelectedItem.V alue)
End If
End Sub
Private Sub ddlClient_Selec tedIndexChanged (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles ddlClient.Selec tedIndexChanged
gentable()
End Sub
Private Sub ddlManufacturer _SelectedIndexC hanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles ddlManufacturer .SelectedIndexC hanged
gentable()
End Sub
Private Sub gentable()
Dim dtGenClient As DataTable
Dim objGenClientNum bers As New ClientProductMa nufacturerDetai ls
dtGenClient = objGenClientNum bers.GenClientN umbers(Session( "FP_CompanyID") , ddlManufacturer .SelectedItem.V alue, ddlClient.Selec tedItem.Value)
Dim lit As LiteralControl
Dim cell As TableCell
Dim dr As DataRow
If ((ddlClient.Sel ectedIndex > 0) And (ddlManufacture r.SelectedIndex > 0)) Then
For Each dr In dtGenClient.Row s
Dim row As New TableRow
tblClientNumber .Rows.Add(row)
lit = New LiteralControl( dr("ClientNumbe r").ToString )
cell = New TableCell
cell.Controls.A dd(lit)
cell.Horizontal Align = HorizontalAlign .Center
row.Cells.Add(c ell)
If (dr("inuse") = 0) Then
buildimagebutto n(row, dr("FP_Manufact urerClientNumbe rID"))
Else
buildimagebutto n(row, Nothing)
End If
Next
If dtGenClient.Row s.Count <= 0 Then
Label1.Visible = True
Else
Label1.Visible = False
End If
End If
End Sub
Private Sub buildimagebutto n(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.CommandA rgument = cid
cell.Controls.A dd(imgBtn)
cell.Horizontal Align = HorizontalAlign .Center
cell.VerticalAl ign = VerticalAlign.M iddle
row.Cells.Add(c ell)
End Sub
Sub imgBtn_Click(By Val sender As System.Object, ByVal e As System.Web.UI.W ebControls.Comm andEventArgs)
Dim objdel As New ClientProductMa nufacturerDetai ls
objdel.delManuf acturerClientNu mber(Session("F P_CompanyID"), e.CommandArgume nt)
End Sub
End Class
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.Sql Client
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Public Class mbrSetClientMan ufacturer
Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
Protected WithEvents ddlProductType As System.Web.UI.W ebControls.Drop DownList
Protected WithEvents ddlManufacturer As System.Web.UI.W ebControls.Drop DownList
Protected WithEvents btnAdd As System.Web.UI.W ebControls.Butt on
Protected WithEvents frmSetProductTy pe As System.Web.UI.H tmlControls.Htm lForm
Protected WithEvents tblProductTypeN umber As System.Web.UI.W ebControls.Tabl e
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected WithEvents ddlClient As System.Web.UI.W ebControls.Drop DownList
Protected WithEvents tblClientNumber As System.Web.UI.W ebControls.Tabl e
Protected WithEvents frmSetClient As System.Web.UI.H tmlControls.Htm lForm
Protected WithEvents imgBtn As System.Web.UI.W ebControls.Imag eButton
Protected WithEvents TextBox1 As System.Web.UI.W ebControls.Text Box
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
btnAdd.Attribut es.Add("onclick ", "return validate();")
If Not Page.IsPostBack Then
Dim dtManufacturer As New DataTable
Dim dtClient As New DataTable
Dim objClientManufa cturer As New ClientProductMa nufacturerDetai ls
dtClient = objClientManufa cturer.grsClien tNamelist(Sessi on("FP_companyI d"))
dtManufacturer = objClientManufa cturer.grsManuf acturerName(Ses sion("FP_compan yId"))
ddlClient.Items .Add(New ListItem("selec t from..", 0))
ddlManufacturer .Items.Add(New ListItem("selec t from..", 0))
Dim drClient As DataRow
For Each drClient In dtClient.Rows
ddlClient.Items .Add(New ListItem(drClie nt("ClientName" ).ToString, drClient("FP_Cl ientID").ToStri ng))
Next
Dim drManufacturer As DataRow
For Each drManufacturer In dtManufacturer. Rows
ddlManufacturer .Items.Add(New ListItem(drManu facturer("Suppl ierName").ToStr ing, drManufacturer( "FP_ProductSupp lierCompanyID") .ToString))
Next
Dim modesave As String
modesave = Request.QuerySt ring.Item("mode ")
If (modesave = "frmsav") Then
gentable()
ddlClient.Selec tedValue = Request.QuerySt ring.Item("FP_C lientID").ToStr ing
ddlManufacturer .SelectedValue = Request.QuerySt ring.Item("FP_P roductSupplierC ompanyID").ToSt ring
modesave = " "
End If
End If
End Sub
Private Sub btnAdd_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles btnAdd.Click
If (ddlClient.Sele ctedIndex <> 0) And (ddlManufacture r.SelectedIndex <> 0) Then
Response.Redire ct("mbrSetClien tManufacturerEd it.aspx?FP_Clie ntID=" & ddlClient.Selec tedItem.Value & "&FP_ProductSup plierCompanyID= " & ddlManufacturer .SelectedItem.V alue)
End If
End Sub
Private Sub ddlClient_Selec tedIndexChanged (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles ddlClient.Selec tedIndexChanged
gentable()
End Sub
Private Sub ddlManufacturer _SelectedIndexC hanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles ddlManufacturer .SelectedIndexC hanged
gentable()
End Sub
Private Sub gentable()
Dim dtGenClient As DataTable
Dim objGenClientNum bers As New ClientProductMa nufacturerDetai ls
dtGenClient = objGenClientNum bers.GenClientN umbers(Session( "FP_CompanyID") , ddlManufacturer .SelectedItem.V alue, ddlClient.Selec tedItem.Value)
Dim lit As LiteralControl
Dim cell As TableCell
Dim dr As DataRow
If ((ddlClient.Sel ectedIndex > 0) And (ddlManufacture r.SelectedIndex > 0)) Then
For Each dr In dtGenClient.Row s
Dim row As New TableRow
tblClientNumber .Rows.Add(row)
lit = New LiteralControl( dr("ClientNumbe r").ToString )
cell = New TableCell
cell.Controls.A dd(lit)
cell.Horizontal Align = HorizontalAlign .Center
row.Cells.Add(c ell)
If (dr("inuse") = 0) Then
buildimagebutto n(row, dr("FP_Manufact urerClientNumbe rID"))
Else
buildimagebutto n(row, Nothing)
End If
Next
If dtGenClient.Row s.Count <= 0 Then
Label1.Visible = True
Else
Label1.Visible = False
End If
End If
End Sub
Private Sub buildimagebutto n(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.CommandA rgument = cid
cell.Controls.A dd(imgBtn)
cell.Horizontal Align = HorizontalAlign .Center
cell.VerticalAl ign = VerticalAlign.M iddle
row.Cells.Add(c ell)
End Sub
Sub imgBtn_Click(By Val sender As System.Object, ByVal e As System.Web.UI.W ebControls.Comm andEventArgs)
Dim objdel As New ClientProductMa nufacturerDetai ls
objdel.delManuf acturerClientNu mber(Session("F P_CompanyID"), e.CommandArgume nt)
End Sub
End Class
Comment