Button click event

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top