Update multiple data in DataGrid

zhaozj2021-02-16  49

Update multiple data in DataGrid

In DataGrid usually we only need to update data, but sometimes updates data in all columns, improve data editing efficiency.

In order to facilitate demonstration to use the XML file as a data source

XML file: (UserInfo.xml)

Some@you.net

me

0123456

YourAddress@you.com

He

7894563

YourAddress@you.com

222

123342

YourAddress@you.com

Haha

3545445

YourAddress@you.com

SAM

879563

Page code:

>>>

IF (Di.ItemType == ListItemType.Item || Di.ItemType == ListItemType.AlternatingItem)

{

DataRow Dr = DSUSER.TABLES ["UserInfo"]. Rows.Find (Di.Id.DataKeys [di.itemindex]);

// If delete is selected.

IF ((Checkbox) Di.FindControl ("chkdelete")). Checked)

{

DSUSER.TABLES ["Userinfo"]. Rows.Remove (DR);

Else

{

// Update

DR ["email"] = ((TextBox) Di.FindControl ("email")). Text;

DR ["" "] = ((TextBox) Di.FindControl (" name ")). Text;

DR [Tel "] = ((TextBox) Di.FindControl (" tel ")). Text;

}

}

}

// If there is a change

IF (DSUSER.HASCHANGES ())

{

Save ();

}

Binddata ();

}

转载请注明原文地址:https://www.9cbs.com/read-21484.html

New Post(0)