I seem to have found many posts in the past. Most of them are the following practices:
Private void maid (object sender, System. Web. UI. WebControls. DataGridItemEventArgs e)
{
For (int I = 0; I <this. DataGrid1.Items. Count; I ++)
{
LinkButton lb = (LinkButton) this. DataGrid1.Items [I]. Controls [3]. Controls [0];
Lb. Attributes. Add ("onclick", "javascript: if (! Window. confirm ('Are you sure you want to delete it? ') Return false ;");
}
}
I don't know why someone posted such code. It seems that the efficiency is not very good. But it's okay. You will receive your own notebook.
But today we have a problem.
Private void maid (object sender, System. Web. UI. WebControls. DataGridItemEventArgs e)
{
If (e. Item. Cells [0]. Text! = Session ["PERSON_ID"]. ToString () // The deletion button is invisible because it is not your own post.
{
If (e. Item. ItemType! = ListItemType. Header)
E. Item. Cells [3]. Text = "";
}
Else
{
LinkButton lb = (LinkButton) e. Item. Cells [3]. Controls [0]);
Lb. Attributes. Add ("onclick", "javascript: if (! Window. confirm ('Are you sure you want to delete it? ') Return false ;");
// You can only use the above method. Otherwise, the index will fail after I delete the Control of e. Item. Cells [3. Code efficiency is also much better.
/*
For (int I = 0; I <this. DataGrid1.Items. Count; I ++)
{
LinkButton lb = (LinkButton) this. DataGrid1.Items [I]. Controls [3]. Controls [0];
Lb. Attributes. Add ("onclick", "javascript: if (! Window. confirm ('Are you sure you want to delete it? ') Return false ;");
}
*/
}
}
}
PS: (I really don't understand. Today, why did we get a homepage original technology area website category? ^_^ 0