the way i did got a reference to the button is:
Dim btn As System.Web.UI.WebControls.Button = e.Item.Cells(4).Controls(0)
btn.Attributes.Add("onclick", "return confirm('Delete record?');")
btn.CausesValidation = False (this doesn't work - how can i do this is another question.)
but somewhere i get the feeling that getting to the button using it's index (that might change tomorrow) and having to take care of this index in order that when it changed the code will not fail is not the state of the art programming practice, i wish someone in this newsgroup will state the microsoft engineers opinion regarding us having to program this way!
"z. f." <> wrote in message news:%...
> how would you get a reference to the buttoncolumn since it does not have an
> ID attribute
>
> <asp:ButtonColumn Text="del" ButtonType="PushButton"
> CommandName="Delete"></asp:ButtonColumn>
>
> and also the findControl method would not cast to the boundColumn type of
> the button - the following line of code will not compile:
> Dim btn As System.Web.UI.WebControls.ButtonColumn =
> CType(e.Item.FindControl("btnDelIDIDID"), ButtonColumn)
>
> TIA,
>
>
>
>
>
> "Steven Spits" <> wrote in message
> news:...
> > "z. f." wrote
> >
> > > i have a datagrid with a delete button for each row in the grid.
> > > when the delete button is clicked i need to ask the user in a "confirm"
> > > message box if he's sure he wants to delete.
> >
> > Get a reference to the delete button in the ItemCreated event of your
> > datagrid, then use:
> >
> > btnDelete.Attributes.Add("onclick", "return confirm('Delete record?');");
> >
> > Steven
> >
> > - - -
> >
> >
> >
>
>
|