473,399 Members | 3,656 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,399 software developers and data experts.

Addhnadler postback problem....plz help asap...

Hi,
I have created some dynamic labels and some dynamic linkbuttons... those linkbuttons have addhandlers assigned to them... but in postback those buttons gets deleted...

the code is shown below... plz help asap...
Expand|Select|Wrap|Line Numbers
  1.     Dim conn As New Data.OleDb.OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
  2.     Dim itable As New Table
  3.     Dim irow As New TableRow
  4.     Dim icell(5), ic(5) As TableCell
  5.     Dim txt As New Label
  6.     Dim prd, sku As Label
  7.     Dim tit As TextBox
  8.     Dim skus As Label
  9.     Dim upd, del As LinkButton
  10.     Dim ic1(7), ic2(7) As TableCell
  11.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  12.         If Not Page.IsPostBack Then
  13.             Dim ds As New Data.DataSet
  14.             Dim select_cat As Data.OleDb.OleDbDataAdapter
  15.             select_cat = New Data.OleDb.OleDbDataAdapter("select name from category order by pos", conn)
  16.             select_cat.Fill(ds, "name")
  17.             catitems.DataSource = ds.Tables(0).DefaultView
  18.             catitems.DataBind()
  19.         End If
  20.         If Page.IsPostBack Then
  21.             plc.Controls.Clear()
  22.             Call headdel()
  23.             Call get_deldata()
  24.         End If
  25.     End Sub
  26.  
  27.     Protected Sub catitems_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles catitems.SelectedIndexChanged
  28.         txt.Text = catitems.SelectedValue
  29.         Call headdel()
  30.     End Sub
  31.     Sub headdel()
  32.         Dim edi, delet, zon, clas As Label
  33.         Dim a As Integer
  34.         For a = 0 To 5
  35.             zon = New Label
  36.             zon.Text = "Product title"
  37.             clas = New Label
  38.             clas.Text = "SKU"
  39.             icell(a) = New TableCell
  40.             edi = New Label
  41.             edi.Text = "Update"
  42.             delet = New Label
  43.             delet.Text = "Delete"
  44.             If a = 0 Then
  45.                 icell(a).Controls.Add(zon)
  46.             End If
  47.             If a = 1 Then
  48.                 icell(a).Controls.Add(clas)
  49.             End If
  50.             If a = 2 Then
  51.                 icell(a).Controls.Add(edi)
  52.             End If
  53.             If a = 3 Then
  54.                 icell(a).Controls.Add(delet)
  55.             End If
  56.         Next
  57.         itable = New Table
  58.         irow = New TableRow
  59.         irow.BorderWidth = 1
  60.         itable.BorderWidth = 1
  61.         itable.Width = 650
  62.         irow.BorderWidth = 1
  63.         itable.Rows.Add(irow)
  64.         irow.Cells.Add(icell(0))
  65.         irow.Cells.Add(icell(1))
  66.         irow.Cells.Add(icell(2))
  67.         irow.Cells.Add(icell(3))
  68.         'plc.Controls.Add(itable)
  69.         Call get_deldata()
  70.     End Sub
  71.     Sub get_deldata()
  72.         Dim conn As New Data.OleDb.OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
  73.         Dim comm As New Data.OleDb.OleDbCommand
  74.         Dim reader As Data.OleDb.OleDbDataReader
  75.         Dim state As String
  76.         Dim b As Integer
  77.         conn.Open()
  78.         state = "select [title],sku from products where cat='" & txt.Text & "'"
  79.         comm = New Data.OleDb.OleDbCommand(state, conn)
  80.         reader = comm.ExecuteReader
  81.         While reader.Read
  82.             irow = New TableRow
  83.             itable.Rows.Add(irow)
  84.             prd = New Label
  85.             sku = New Label
  86.             ic1(0) = New TableCell
  87.             prd.Text = reader.GetValue(0)
  88.             ic1(0).Controls.Add(prd)
  89.             ic1(1) = New TableCell
  90.             sku.Text = reader.GetValue(1)
  91.             ic1(1).Controls.Add(sku)
  92.             itable.Rows.Add(irow)
  93.             irow.Cells.Add(ic1(0))
  94.             irow.Cells.Add(ic1(1))
  95.             Dim conn1 As New Data.OleDb.OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
  96.             Dim comm1 As New Data.OleDb.OleDbCommand
  97.             Dim reader1 As Data.OleDb.OleDbDataReader
  98.             Dim state1 As String
  99.             conn1.Open()
  100.             state1 = "select [sku],[prdtitle],[ID] from [prdfake] where [sku]='" & reader.GetValue(1) & "'"
  101.             comm1 = New Data.OleDb.OleDbCommand(state1, conn1)
  102.             reader1 = comm1.ExecuteReader
  103.             While reader1.Read
  104.                 upd = New LinkButton
  105.                 upd.Text = "Update"
  106.                 'AddHandler upd.Click, AddressOf updbtn
  107.                 'upd.ID = "ty" & reader.GetValue(1)
  108.                 del = New LinkButton
  109.                 del.Text = "Delete"
  110.                 del.ID = "dt" & reader1.GetValue(0)
  111.                 AddHandler del.Click, AddressOf delbtn
  112.                 For b = 0 To 5
  113.                     tit = New TextBox
  114.                     tit.Text = reader1.GetValue(1)
  115.                     skus = New Label
  116.                     skus.Text = reader1.GetValue(0)
  117.                     ic2(b) = New TableCell
  118.                     If b = 0 Then
  119.                         ic2(b).Controls.Add(tit)
  120.                         ic2(b).Width = "100"
  121.                     End If
  122.                     If b = 1 Then
  123.                         ic2(b).Controls.Add(skus)
  124.                         ic2(b).Width = "100"
  125.                     End If
  126.                     If b = 2 Then
  127.                         ic2(b).Controls.Add(upd)
  128.                         ic2(b).Width = "50"
  129.                     End If
  130.                     If b = 3 Then
  131.                         ic2(b).Controls.Add(del)
  132.                         ic2(b).Width = "150"
  133.                     End If
  134.                 Next
  135.                 irow = New TableRow
  136.                 itable.Rows.Add(irow)
  137.                 irow.Cells.Add(ic2(0))
  138.                 irow.Cells.Add(ic2(1))
  139.                 irow.Cells.Add(ic2(2))
  140.                 irow.Cells.Add(ic2(3))
  141.             End While
  142.             conn1.Close()
  143.             comm1.Dispose()
  144.             conn1.Dispose()
  145.             Dim add As LinkButton
  146.             add = New LinkButton
  147.             add.ID ="a" & reader.GetValue(1)
  148.             add.Text = "Add new title"
  149.             AddHandler add.Click, AddressOf show
  150.             ic2(4) = New TableCell
  151.             ic2(4).Controls.Add(add)
  152.             ic2(4).Width = "100"
  153.             irow.Cells.Add(ic2(4))
  154.         End While
  155.         conn.Close()
  156.         comm.Dispose()
  157.         conn.Dispose()
  158.         plc.Controls.Add(itable)
  159.     End Sub
  160.     Public Sub show(ByVal sender As Object, ByVal e As EventArgs)
  161.         Call headdel()
  162.         Call get_deldata()
  163.     End Sub
  164.     Public Sub delbtn(ByVal sender As Object, ByVal e As EventArgs)
  165.         Dim t As Integer = sender.ToString.Length
  166.         Dim conn3 As New Data.OleDb.OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
  167.         Dim comm3 As New Data.OleDb.OleDbCommand
  168.         Dim state3 As String
  169.         Try
  170.             Dim t1 As New Label
  171.             t1.Text = "Product Title"
  172.             state3 = "insert into [prdfake]([sku],[prdtitle]) values('" & t1.Text & "','" & t1.Text & "')"
  173.             comm3 = New Data.OleDb.OleDbCommand(state3, conn3)
  174.             conn3.Open()
  175.             comm3.ExecuteNonQuery()
  176.         Catch ex As Exception
  177.             Response.Write(ex.Message)
  178.         Finally
  179.             If Not conn3 Is Nothing Then
  180.                 conn3.Close()
  181.             End If
  182.             conn3.Dispose()
  183.             comm3.Dispose()
  184.             Call headdel()
  185.         End Try
  186.     End Sub
Aug 31 '08 #1
3 1442
joedeene
583 512MB
please remember to use <code> tages (the '#' button after selecting your code you pasted into the post)

joedeene
Aug 31 '08 #2
plz help me wid this........
Aug 31 '08 #3
Curtis Rutland
3,256 Expert 2GB
joedeene asked you once to use code tags. I've deleted your other post where you just re-paste your code.

Please read the Posting Guidelines.

MODERATOR
Sep 1 '08 #4

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

Similar topics

5
by: MrMike | last post by:
I have a datagrid containing a drop-down-list. The datagrid contains Edit,Update,Cancel buttons and respective events. Whenever I make a change to one particular field (a drop-down-list in...
1
by: Joseph Luner | last post by:
I am having problem postback, (code shown below) the variable "my_str" is lost after clicking the "submit" button. Isn't it suppose to display "changed" after posting back? Is there anyway I...
1
by: Frankieboy | last post by:
I believe I've got a postback problem on our site. The strange thing is that everything works fine on my developing version, but not on the production site. I'm wondering if there may be different...
0
by: bill yeager | last post by:
I have a simple button and textbox on a webform with a RequiredFieldValidator tied to the textbox control. The problem is that a postback never occurs on the webform by clicking the button even...
0
by: phl | last post by:
hello, I have an input control which saves a file user specifies. Like this : SaveCon.PostedFile.SaveAs(sDocPath) This cause a postback which presents a problem as I want this to happen in my...
4
by: Daniel Groh | last post by:
I have two controls in my webform, BUT....one comes from a user control and the other comes from another user control, both with post back! How can i work just with one PostBack ? if(PostPack...
6
by: | last post by:
Hi all, I have a bunch of dropdownlists that are populated in client-side javascript. When i do a postback I get the following error:- Invalid postback or callback argument. Event...
9
by: Alper OZGUR | last post by:
Hi; In my code i'm checking some conditions and if the condition fails i want to postback the page. Tried using the below methods but the when form is loaded the postback status is false.. how can...
2
by: VSingh | last post by:
I have a form in a C# ASP Dotnet application. There is code in both the !Postback and Postback section. The code in Postback section always executes on the development box but when I deploy the app...
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: 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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.