OnClick event

S

simon

If I put button into the header of my DataGrid:

<asp:TemplateColumn>
<HeaderTemplate><asp:Button ID=btnNew Text="New Type"
Runat=server></asp:Button></HeaderTemplate>
<ItemTemplate>
.....

and in codeBehind:

Private Sub btnNew_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnNew.Click
dgdMediaType.CurrentPageIndex = 0
dgdMediaType.DataBind()
dgdMediaType.ShowFooter = True
End Sub

nothing hapens. The onclick event is not fired.

But if I put ><asp:Button ID=btnNew Text="New Type"
Runat=server></asp:Button> somewhere else on the page, outside the datagrid,
then everything works, onClick event is fired.

Why?

Thank you for your answer,
Simon
 
A

avnrao

when button is in datagrid, you should handle the event seperately. even if
you create btnNew_Click, how did you map it to the button?

rather you should check in dataGrid Item Command method, check for e.Command
and see if its your button.

Av.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top