Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Addhandler - Linkbutton problem

Status
Not open for further replies.

adalli

Programmer
Feb 8, 2005
44
MT
Hi,

I am having problems with AddHandlers. These are being fired on alternate clicks. First time they work, second time no, third time they work and fourth no etc ...

I have the following code in Page_Load part

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
ExtractAllTasks()
End Sub

Private Sub ExtractAllTasks()
tblOverDue.Rows.Clear()

Dim myCell As TableCell
Dim myRow As TableRow

.
.
.
.

If drDataReader.HasRows Then
While drDataReader.Read
strButtonID = incremental Value

myCell = New TableCell()
lbButton = New LinkButton
lbButton.Text = "Complete?"
lbButton.CommandArgument = strButtonID
AddHandler lbButton.Command, AddressOf Me.CompleteTask
myCell.Width = 50
lbButton.ForeColor = Drawing.Color.Blue
myCell.BackColor = AlternateColor
lbButton.Font.Underline = False
myCell.Controls.Add(lbButton)
myRow.Cells.Add(myCell)
tblOverDue.Rows.Add(myRow)
.
.
.
.
END SUB

Can anyone please help?

 
2 things.
1.) do you want the ExtractAllTasks() to be called on each post back?

2.) Not sure if this will solve your problem, but you do not create a unique ID for each link button you add to the form. Try adding a name for each and see if that helps.
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top