|
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!!!!!!!!!!!!! |
|