hi all, to give a alert before deleting a recored form gridview u can use this code. First u place a linkbutton in gridview colums as shown below. COde: AutoGenerateColumns="False" Width="100%" OnRowEditing="gvdemo_RowEditing" DataKeyNames="bigint_DemoId" OnRowDataBound="gvdemo_RowDataBound" OnRowCommand="gvdemo_RowCommand"> Delete
COde For DElete link Button separately: Delete
COde To Add ALert : For this we use Grid view Row bound event code: protected void gvdemo_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Button imgdelete = (Button)e.Row.FindControl("imgdelete");//Find the button imgdelete.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete " + DataBinder.Eval(e.Row.DataItem, "var_DemoDate") + " " + DataBinder.Eval(e.Row.DataItem, "var_DemoTime") + "')");// alert adding } }
Happy coding...
|
No responses found. Be the first to respond and make money from revenue sharing program.
|