| |

VerySource

 Forgot password?
 Register
Search
View: 729|Reply: 6

How to delete multiple checked records (in gridview) with one button in asp?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-5 16:30:02
| Show all posts |Read mode
Please heroes give the code in cs, thank you
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-24 17:30:02
| Show all posts
Delete one by one? ? ?
Waiting for a master answer ...
Reply

Use magic Report

0

Threads

14

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-3-25 00:30:01
| Show all posts
It is definitely better to delete one by one with the in clause ... but I will not -_-
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-31 16:00:01
| Show all posts
string del = "";
Throw all checked data into del. then
delete from table Where id in ("+ del +")
Reply

Use magic Report

0

Threads

24

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-4-1 18:30:01
| Show all posts
LZ, show you my cs code:
// Delete the selected button event
    protected void deleteSelectedBtn_Click (object sender, EventArgs e)
    {
        int intFlag = 0;
        for (int i = 0; i <this.ShowMailGridView.Rows.Count; i ++)
        {
            GridViewRow row = this.ShowMailGridView.Rows [i];
            HtmlInputCheckBox selectedChkbox = (HtmlInputCheckBox) row.FindControl ("selectedchkbox") as System.Web.UI.HtmlControls.HtmlInputCheckBox;
            if (selectedChkbox! = null&&selectedChkbox.Checked)
            {
                int InfoId = Convert.ToInt32 (selectedChkbox.Value);
                intFlag = Mail.DeleteMail (InfoId);
            }
        }
        if (intFlag> 0)
        {
            thisShowMailGridViewDataBind ();
        }

    }
    // Delete all button events
    protected void deleteAllBtn_Click (object sender, EventArgs e)
    {
        int intFlag = 0;
        for (int i = 0; i <this.ShowMailGridView.Rows.Count; i ++)
        {
            GridViewRow row = this.ShowMailGridView.Rows [i];
            HtmlInputCheckBox selectedChkbox = (HtmlInputCheckBox) row.FindControl ("selectedchkbox") as System.Web.UI.HtmlControls.HtmlInputCheckBox;
            if (selectedChkbox! = null)
            {
                int InfoId = Convert.ToInt32 (selectedChkbox.Value);
                intFlag = Mail.DeleteMail (InfoId);
            }
        }
        if (intFlag> 0)
        {
            thisShowMailGridViewDataBind ();
        }
       

    }
Reply

Use magic Report

0

Threads

24

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-4-1 23:45:01
| Show all posts
ItemTemplate code in HTML, gridview
<ItemTemplate>
                          <table border = "0" cellpadding = "0" cellspacing = "0" width = "100%">
                             <tr align = "left" style = "font-weight: normal; font-size: 9pt" valign = "middle">
                                 <td width = "4%" align = "center">
                                    <input type = "checkbox" id = "selectedchkbox" value = '<% # DataBinder.Eval (Container.DataItem, "InfoID")%>' runat = "server" /> </ td>
                                 <td width = "4%" align = "center> </ td>
                                 <td align = "left" valign = "middle" width = "35%">
                                    <a href="LookMail.aspx?MailId=<%#DataBinder.Eval(Container.DataItem,"MailID")%> "target =" _ self "> <font color =" # 9933ff "> <% DataBinder.Eval ( Container.DataItem, "Subject")%> </ font> </a>
                                 </ td>
                                 <td align = "center" valign = "middle" width = "15%">
                                    <% # DataBinder.Eval (Container.DataItem, "UserID")%>
                                 </ td>
                                  <td align = "center" valign = "middle" width = "15%">
                                    <% = ReceiversNamelbstring%>
                                 </ td>
                                  <td align = "center" valign = "middle" width = "15%">
                                    <% # DataBinder.Eval (Container.DataItem, "SendDate", "{0: yyyy-MM-dd HH: mm}")%>
                                 </ td>
                              
                                  <td align = "center" valign = "middle" width = "12%">
                                        
                                  </ td>
                             </ tr>
                            </ table>
                        </ ItemTemplate>
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-15 21:30:01
| Show all posts
Thank you all.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list