Button click event

  • Thread starter Thread starter James Page
  • Start date Start date
J

James Page

Hi all

Have a problem setting a button’s click event.

The button is in a DetailsView row which is nested within a Gridview.
I need to set its click event to pass a value held in a label within the
same row and pass that value to a function.

I have no problems referencing the controls using:

Dim id as string
Dim dl As DataList = row.FindControl("DataList1")
For Each l As DataListItem In dl.Items
Dim ctlBtn As Button = l.FindControl("btn1")
Dim ctlLbl As Label = l.FindControl("label1")
id = ctlLbl.Text
Next

But how do i set the click event and do somthing meaningful with the code??

Any ideas?


Thanks
 
Hi all

Have a problem setting a button’s click event.

The button is in a DetailsView row which is nested within a Gridview.
I need to set its click event to pass a value held in a label within the
same row and pass that value to a function.

I have no problems referencing the controls using:

Dim id as string
Dim dl As DataList = row.FindControl("DataList1")
For Each l As DataListItem In dl.Items
Dim ctlBtn As Button = l.FindControl("btn1")
Dim ctlLbl As Label = l.FindControl("label1")
id = ctlLbl.Text
Next

But how do i set the click event and do somthing meaningful with the code??

Any ideas?

Thanks

Hi James,

Use EventHandler to register the event-handling method
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.click.aspx

Hope this helps
 
Back
Top