I want to embed a button control in the DataGrid. I don't want to put it in Delete.
In itemcreated, I write as follows:
Foreach (maid di in this. Maid)
{
If (Di. itemtype = listitemtype. Item | Di. itemtype = listitemtype. alternatingitem)
{
(Button) Di. cells [6]. controls [0]). Attributes. Add ("onclick", "Return confirm ('Are you sure you want to reset the password of this user? ');");
}
}
Always report:
The specified conversion is invalid.
If I write:
Foreach (maid di in this. Maid)
{
If (Di. itemtype = listitemtype. Item | Di. itemtype = listitemtype. alternatingitem)
{
Button btn_pwdreset = (button) (E. Item. findcontrol ("btn_pwdreset "));
Btn_pwdreset.attributes.add ("onclick", "Return confirm ('Are you sure you want to reset the password of this user? ');");
}
}
Always report:
The instance where the object reference is not set to the object
How can I find this control?
How can I add a click event to this control?