| |

VerySource

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

c # website, how to add, delete, modify datagride on the client

[Copy link]

3

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-29 10:20:01
| Show all posts |Read mode
I just came into contact with C #, and now I want to use him as a website. The client must use DATAGRIDE to display the data in the database, and then the user can click on the data of DATAGRIDE to delete, modify, or insert data, and finally submit the data to Database, trouble masters how to realize how to achieve, if you can, can give the source code, thank you little girl.
Reply

Use magic Report

0

Threads

64

Posts

45.00

Credits

Newbie

Rank: 1

Credits
45.00

 China

Post time: 2020-3-4 19:15:01
| Show all posts
Each row of Datagrid should have a delete and modify button, and then click the button to trigger the Itemcommound event, and implement the modification and deletion in the event.
Reply

Use magic Report

0

Threads

64

Posts

45.00

Credits

Newbie

Rank: 1

Credits
45.00

 China

Post time: 2020-3-6 08:15:01
| Show all posts
autogenerateDeletebutton
autogenerateeditbutton
These two Dongdong are not used to it, it is recommended to write your own method, seeing this is comfortable
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-13 09:15:01
| Show all posts
Click the data of DATAGRIDE to delete, modify, or insert data, and finally submit the data to the database
Delete the data in the DataGrid: I want to make a checkBox template column in the DataGrid to get the number of rows to be deleted by ticking.
//Get the number of options
int selectCount = 0;
for(int i=0; i<dgUserList.Items.Count; i++)
{
CheckBox chk = (CheckBox)dgUserList.Items[i].FindControl("chkSelected");
         if(chk.Checked)
selectCount++;
}

//Get the selected user ID
int[] ids = new int[selectCount];
int j = 0;
for(int i=0; i<dgUserList.Items.Count; i++)
{
   CheckBox chk = (CheckBox)dgUserList.Items[i].FindControl("chkSelected");
   if(chk.Checked)
   ids[j++] =Convert.ToInt32(dgUserList.Items[i].Cells[1].Text);
}

Add and modify the data of the DataGrid: I want to do it through another page.
Modify: Make a hyperlink column in the DataGrid, click the row to be modified, and transfer the data to be modified in the DataGrid to another page. After the modification, redirect to your display page.
Add: another page pops up through the add button, and redirect to your display page after adding;
Response.Redirect();
The above is my personal point of view.Regarding whether data can be directly added, deleted, and modified in the DataGrid, further research is needed.
The above process is carried out through the operation of the database, and it is only displayed in the DataGrid.
I posted for the first time and celebrate!!!!!!!!!!!!!
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-13 12:00:01
| Show all posts
It allows users to edit the information in the grid rows in-place. To do this, you need to use the Property Builder to create the "Edit, Update, Cancel" column and add code to the DataGrid's EditCommand, UpdateCommand, and CancelCommand events. At run time, this column displays a button labeled "Edit". When the user clicks the "Edit" button, the row data is displayed in an editable control such as a text box, and the "Edit" button is replaced with the "Update" and "Cancel" buttons. Clicking the "Update" button raises the UpdateCommand event, which adds code to propagate the data changes back to the data source. Click the "Cancel" button to raise the CancelCommand event, add code to this event to rebind the original data to the DataGrid

The DataGrid can be set up so that users can delete specific rows by clicking a button. There are three ways to create a "delete" button. you can:

Create "Delete" button by "Property Builder"
Create the button yourself in the "Property Builder"
Add the button to the template column
In each case, create a Button control with a CommandName property of "Delete". Then add code to the DeleteCommand event to delete the item from the data source.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-13 13:00:02
| Show all posts
This is the most basic thing
Find a datagrid tutorial and see
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-13 15:15:01
| Show all posts
Halo, there are a lot of original codes on the network about the function you want, why don't you search?
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