Delete record
am 31.03.2008 18:45:44 von CreativeMind
hi all,
private void dgMygrid_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
Button bDelete=(Button)e.Item.FindControl("btnDelete");
if(bDelete!=null)
{
bDelete.Attributes.Add("OnClick","javascript:return confirm('Are
you sure you want to delete this sales person?');");
// if user clicks ok, then i want to call deleteRecord(); Question is
how i trace 'ok'?
ie. // if ok then delete record else do nothing.
}
}
Re: Delete record
am 01.04.2008 11:56:31 von arnabit
On Mar 31, 9:45=A0pm, CreativeMind wrote:
> hi all,
> private void dgMygrid_ItemCreated(object sender,
> System.Web.UI.WebControls.DataGridItemEventArgs e)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Button bDelete=3D(Button)e=
..Item.FindControl("btnDelete");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(bDelete!=3Dnull)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bDelete.At=
tributes.Add("OnClick","javascript:return confirm('Are
> you sure you want to delete this sales person?');");
> // if user clicks ok, then i want to call deleteRecord(); Question is
> how i trace 'ok'?
> ie. // if ok then delete record else do nothing.
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
call a javascript function form onclinetclick for the "btnDelete"
button.
Inside the function write the following code
function confirm()
{
var returnvalue =3D window.confirm('Are you sure you want to delete
this sales person?');");
return returnvalue ;
}
in code behind write
private void dgMygrid_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
Button
bDelete=3D(Button)e.Item.FindControl("btnDelete");
//delete function();
}