| |

VerySource

 Forgot password?
 Register
Search
View: 829|Reply: 7

datagrid "delete" "select" rebind issue

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-8 14:40:01
| Show all posts |Read mode
My data source was redefined by myself, now every time I click "Delete", an error will be reported
"GridView" GridView1 "fired the unhandled event" RowDeleting "
Same with "choice"
Is to rebind the data, but how to bind it
Reply

Use magic Report

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

Post time: 2020-1-9 14:36:01
| Show all posts
Redefine these events in the datagrid event and try it out
Reply

Use magic Report

0

Threads

43

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-1-9 15:09:01
| Show all posts
Delete and select events are not defined
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-9 15:18:01
| Show all posts
redefine? How to redefine it? Hope advice
Reply

Use magic Report

1

Threads

18

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-1-9 23:09:01
| Show all posts
Add delete and select events
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-10 09:27:01
| Show all posts
How to write specific code
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-18 22:00:01
| Show all posts
private void dgShow_DeleteCommand (object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (dgShow.Items.Count == 1)
{
if (dgShow.CurrentPageIndex! = 0)
dgShow.CurrentPageIndex = dgShow.CurrentPageIndex-1;
}
string strSql = "delete from tbStudentinfo where studentid =" + e.Item.Cells [0] .Text + "";
ExecuteSql (strSql);
BindData ();

} This is the deleted full code
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-18 22:36:01
| Show all posts
If it is deleted using Button, here is the code for Button deletion
private void btnDelete_Click (object sender, System.EventArgs e)
{
foreach (DataGridItem dgi in dgShow.Items)
{
CheckBox cb = (CheckBox) dgi.FindControl ("cbSelect");
if (cb.Checked)
{
// The following delete operation is performed
int nID = int.Parse (dgi.Cells [0] .Text);
string strSql = "delete from tbStudentinfo where studentid =" + nID;
ExecuteSql (strSql);
}
}
dgShow.CurrentPageIndex = 0;
BindData ();
}
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