By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,841 Members | 840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,841 IT Pros & Developers. It's quick & easy.

OnClick event

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"simon" <si*********@stud-moderna.si> wrote in message
news:eC**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.