Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Delete confirm() in gride view

Delete confirm() in gride view

Scheduled Pinned Locked Moved ASP.NET
databasedesignsysadminannouncementcareer
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    toufiq_raja
    wrote on last edited by
    #1

    //file1.aspx <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TxtJobID" runat="server"></asp:TextBox> <asp:TextBox ID="TxtJobTitle" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Update" OnClientClick="return confirm('Are You Sure');" Font-Bold="True" /> <br /> <br /> <asp:Label ID="lblMessage" runat="server" Text="Label" Width="474px" style="background-color: #00cccc"></asp:Label><br /> <br /> <asp:DataGrid id="DataGrid1" OnItemCommand="ItemCommand" style="Z-INDEX: 101; LEFT: 175px; TOP: 105px" runat="server" CssClass="tx-tbl-Gr-lml" Width="474px" AllowPaging="true" > <Columns> <asp:ButtonColumn Text="Edit" ButtonType="PushButton" CommandName="Edit"> </asp:ButtonColumn> <asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete"> </asp:ButtonColumn> </Columns> </asp:DataGrid><br /> </div> </form> </body> //file1.aspx.cs public partial class _Default : System.Web.UI.Page { OracleConnection cn; OracleCommand cmd; protected void Page_Load(object sender, EventArgs e) { cn = new OracleConnection("data source=dev;user id=hr;password=hr"); if (!Page.IsPostBack) { BindData(); } } void BindData() { string strsql = "select job_id,job_title from jobs"; OracleDataAdapter da = new OracleDataAdapter(strsql, cn); DataTable dt = new DataTable(); da.Fill(dt); DataGrid1.DataSource = dt; DataGrid1.DataBind(); } protected void ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "Edit") { FillTheData(e.Item.Cells[2].Text, e.Item.Cells[3].Text); lblMessage.Text = ""; } if (e.CommandName == "Delete") { lblMessage.Text = "Need Code to call confirm() frunction "; } } void FillTheData(string job_id, string job_title) { TxtJobID.Text = job_id; TxtJobTitle.Text = job_title; } protected void Button1_Click(object sender, EventArgs e) { try {

    K E K 3 Replies Last reply
    0
    • T toufiq_raja

      //file1.aspx <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TxtJobID" runat="server"></asp:TextBox> <asp:TextBox ID="TxtJobTitle" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Update" OnClientClick="return confirm('Are You Sure');" Font-Bold="True" /> <br /> <br /> <asp:Label ID="lblMessage" runat="server" Text="Label" Width="474px" style="background-color: #00cccc"></asp:Label><br /> <br /> <asp:DataGrid id="DataGrid1" OnItemCommand="ItemCommand" style="Z-INDEX: 101; LEFT: 175px; TOP: 105px" runat="server" CssClass="tx-tbl-Gr-lml" Width="474px" AllowPaging="true" > <Columns> <asp:ButtonColumn Text="Edit" ButtonType="PushButton" CommandName="Edit"> </asp:ButtonColumn> <asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete"> </asp:ButtonColumn> </Columns> </asp:DataGrid><br /> </div> </form> </body> //file1.aspx.cs public partial class _Default : System.Web.UI.Page { OracleConnection cn; OracleCommand cmd; protected void Page_Load(object sender, EventArgs e) { cn = new OracleConnection("data source=dev;user id=hr;password=hr"); if (!Page.IsPostBack) { BindData(); } } void BindData() { string strsql = "select job_id,job_title from jobs"; OracleDataAdapter da = new OracleDataAdapter(strsql, cn); DataTable dt = new DataTable(); da.Fill(dt); DataGrid1.DataSource = dt; DataGrid1.DataBind(); } protected void ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "Edit") { FillTheData(e.Item.Cells[2].Text, e.Item.Cells[3].Text); lblMessage.Text = ""; } if (e.CommandName == "Delete") { lblMessage.Text = "Need Code to call confirm() frunction "; } } void FillTheData(string job_id, string job_title) { TxtJobID.Text = job_id; TxtJobTitle.Text = job_title; } protected void Button1_Click(object sender, EventArgs e) { try {

      K Offline
      K Offline
      keyur satyadev
      wrote on last edited by
      #2

      define your problem rather then code? put your question first and then put the code.

      T 1 Reply Last reply
      0
      • T toufiq_raja

        //file1.aspx <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TxtJobID" runat="server"></asp:TextBox> <asp:TextBox ID="TxtJobTitle" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Update" OnClientClick="return confirm('Are You Sure');" Font-Bold="True" /> <br /> <br /> <asp:Label ID="lblMessage" runat="server" Text="Label" Width="474px" style="background-color: #00cccc"></asp:Label><br /> <br /> <asp:DataGrid id="DataGrid1" OnItemCommand="ItemCommand" style="Z-INDEX: 101; LEFT: 175px; TOP: 105px" runat="server" CssClass="tx-tbl-Gr-lml" Width="474px" AllowPaging="true" > <Columns> <asp:ButtonColumn Text="Edit" ButtonType="PushButton" CommandName="Edit"> </asp:ButtonColumn> <asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete"> </asp:ButtonColumn> </Columns> </asp:DataGrid><br /> </div> </form> </body> //file1.aspx.cs public partial class _Default : System.Web.UI.Page { OracleConnection cn; OracleCommand cmd; protected void Page_Load(object sender, EventArgs e) { cn = new OracleConnection("data source=dev;user id=hr;password=hr"); if (!Page.IsPostBack) { BindData(); } } void BindData() { string strsql = "select job_id,job_title from jobs"; OracleDataAdapter da = new OracleDataAdapter(strsql, cn); DataTable dt = new DataTable(); da.Fill(dt); DataGrid1.DataSource = dt; DataGrid1.DataBind(); } protected void ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "Edit") { FillTheData(e.Item.Cells[2].Text, e.Item.Cells[3].Text); lblMessage.Text = ""; } if (e.CommandName == "Delete") { lblMessage.Text = "Need Code to call confirm() frunction "; } } void FillTheData(string job_id, string job_title) { TxtJobID.Text = job_id; TxtJobTitle.Text = job_title; } protected void Button1_Click(object sender, EventArgs e) { try {

        E Offline
        E Offline
        Expert Coming
        wrote on last edited by
        #3

        AJAX has a way to do a confirm. Pretty simple too, and an example found on the AJAX site.

        The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo

        1 Reply Last reply
        0
        • K keyur satyadev

          define your problem rather then code? put your question first and then put the code.

          T Offline
          T Offline
          toufiq_raja
          wrote on last edited by
          #4

          the problem is that i want to add confirmation from the user to delete the record when the delete button is pressed in the grid. i have the code to delete the record. Just need help how to call the cofirm() javascript function. and what changes should i make in the code to call the function //file1.aspx <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TxtJobID" runat="server"></asp:TextBox> <asp:TextBox ID="TxtJobTitle" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Update" OnClientClick="return confirm('Are You Sure');" Font-Bold="True" /> <br /> <br /> <asp:Label ID="lblMessage" runat="server" Text="Label" Width="474px" style="background-color: #00cccc"></asp:Label><br /> <br /> <asp:DataGrid id="DataGrid1" OnItemCommand="ItemCommand" style="Z-INDEX: 101; LEFT: 175px; TOP: 105px" runat="server" CssClass="tx-tbl-Gr-lml" Width="474px" AllowPaging="true" > <Columns> <asp:ButtonColumn Text="Edit" ButtonType="PushButton" CommandName="Edit"> </asp:ButtonColumn> <asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete"> </asp:ButtonColumn> </Columns> </asp:DataGrid><br /> </div> </form> </body> //file1.aspx.cs public partial class _Default : System.Web.UI.Page { OracleConnection cn; OracleCommand cmd; protected void Page_Load(object sender, EventArgs e) { cn = new OracleConnection("data source=dev;user id=hr;password=hr"); if (!Page.IsPostBack) { BindData(); } } void BindData() { string strsql = "select job_id,job_title from jobs"; OracleDataAdapter da = new OracleDataAdapter(strsql, cn); DataTable dt = new DataTable(); da.Fill(dt); DataGrid1.DataSource = dt; DataGrid1.DataBind(); } protected void ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "Edit") { FillTheData(e.Item.Cells[2].Text, e.Item.Cells[3].Text); lblMessage.Text = ""; } if (e.CommandName == "Delete") { lblMessage.Text = "Need Code to call confirm() frunction "; } } void FillTheData(string job_id, string job_title) { TxtJobID.Text = job_id; TxtJobTitle.Text = job_title; } protected void Button1_Click(object sender, EventArgs e) { try { string strsql = "Update jobs set job_title="+"'"+TxtJobTitle.Text+"'"+" where job_id="+"'"+TxtJobID.Text+"'"; cmd = new OracleCommand(strsql, cn);

          K 1 Reply Last reply
          0
          • T toufiq_raja

            //file1.aspx <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TxtJobID" runat="server"></asp:TextBox> <asp:TextBox ID="TxtJobTitle" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Update" OnClientClick="return confirm('Are You Sure');" Font-Bold="True" /> <br /> <br /> <asp:Label ID="lblMessage" runat="server" Text="Label" Width="474px" style="background-color: #00cccc"></asp:Label><br /> <br /> <asp:DataGrid id="DataGrid1" OnItemCommand="ItemCommand" style="Z-INDEX: 101; LEFT: 175px; TOP: 105px" runat="server" CssClass="tx-tbl-Gr-lml" Width="474px" AllowPaging="true" > <Columns> <asp:ButtonColumn Text="Edit" ButtonType="PushButton" CommandName="Edit"> </asp:ButtonColumn> <asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete"> </asp:ButtonColumn> </Columns> </asp:DataGrid><br /> </div> </form> </body> //file1.aspx.cs public partial class _Default : System.Web.UI.Page { OracleConnection cn; OracleCommand cmd; protected void Page_Load(object sender, EventArgs e) { cn = new OracleConnection("data source=dev;user id=hr;password=hr"); if (!Page.IsPostBack) { BindData(); } } void BindData() { string strsql = "select job_id,job_title from jobs"; OracleDataAdapter da = new OracleDataAdapter(strsql, cn); DataTable dt = new DataTable(); da.Fill(dt); DataGrid1.DataSource = dt; DataGrid1.DataBind(); } protected void ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "Edit") { FillTheData(e.Item.Cells[2].Text, e.Item.Cells[3].Text); lblMessage.Text = ""; } if (e.CommandName == "Delete") { lblMessage.Text = "Need Code to call confirm() frunction "; } } void FillTheData(string job_id, string job_title) { TxtJobID.Text = job_id; TxtJobTitle.Text = job_title; } protected void Button1_Click(object sender, EventArgs e) { try {

            K Offline
            K Offline
            kumar_k508
            wrote on last edited by
            #5

            Hi, You can write the javascript function for the button click....

            A 1 Reply Last reply
            0
            • K kumar_k508

              Hi, You can write the javascript function for the button click....

              A Offline
              A Offline
              anujbanka1784
              wrote on last edited by
              #6

              protected void grd_detail_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[4].Attributes.Add("onClick", "return confirm('Are you sure you want to delete the record?');"); } } use this code in event row data bound of grid view

              1 Reply Last reply
              0
              • T toufiq_raja

                the problem is that i want to add confirmation from the user to delete the record when the delete button is pressed in the grid. i have the code to delete the record. Just need help how to call the cofirm() javascript function. and what changes should i make in the code to call the function //file1.aspx <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TxtJobID" runat="server"></asp:TextBox> <asp:TextBox ID="TxtJobTitle" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Update" OnClientClick="return confirm('Are You Sure');" Font-Bold="True" /> <br /> <br /> <asp:Label ID="lblMessage" runat="server" Text="Label" Width="474px" style="background-color: #00cccc"></asp:Label><br /> <br /> <asp:DataGrid id="DataGrid1" OnItemCommand="ItemCommand" style="Z-INDEX: 101; LEFT: 175px; TOP: 105px" runat="server" CssClass="tx-tbl-Gr-lml" Width="474px" AllowPaging="true" > <Columns> <asp:ButtonColumn Text="Edit" ButtonType="PushButton" CommandName="Edit"> </asp:ButtonColumn> <asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete"> </asp:ButtonColumn> </Columns> </asp:DataGrid><br /> </div> </form> </body> //file1.aspx.cs public partial class _Default : System.Web.UI.Page { OracleConnection cn; OracleCommand cmd; protected void Page_Load(object sender, EventArgs e) { cn = new OracleConnection("data source=dev;user id=hr;password=hr"); if (!Page.IsPostBack) { BindData(); } } void BindData() { string strsql = "select job_id,job_title from jobs"; OracleDataAdapter da = new OracleDataAdapter(strsql, cn); DataTable dt = new DataTable(); da.Fill(dt); DataGrid1.DataSource = dt; DataGrid1.DataBind(); } protected void ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "Edit") { FillTheData(e.Item.Cells[2].Text, e.Item.Cells[3].Text); lblMessage.Text = ""; } if (e.CommandName == "Delete") { lblMessage.Text = "Need Code to call confirm() frunction "; } } void FillTheData(string job_id, string job_title) { TxtJobID.Text = job_id; TxtJobTitle.Text = job_title; } protected void Button1_Click(object sender, EventArgs e) { try { string strsql = "Update jobs set job_title="+"'"+TxtJobTitle.Text+"'"+" where job_id="+"'"+TxtJobID.Text+"'"; cmd = new OracleCommand(strsql, cn);

                K Offline
                K Offline
                keyur satyadev
                wrote on last edited by
                #7

                put the button between span tag. /* */ Regards Keyur Satyadev modified on Thursday, March 12, 2009 8:53 AM

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups