protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowIndex
!=
-
1
)
{
int
id
=
e.Row.RowIndex;
Button btnDel
=
(Button)e.Row.FindControl(
"
btnDel
"
);
//
找刪除按鈕
HtmlButton btnEdit
=
(HtmlButton)e.Row.FindControl(
"
btnEdit
"
);
btnDel.CommandArgument
=
id.ToString();
}
}
protected
void
GridView1_RowCommand(
object
sender, GridViewCommandEventArgs e)
{
if
(e.CommandName
==
"
Del
"
)
{
int
rowIndex
=
Convert.ToInt32(e.CommandArgument);
string
id
=
this
.GridView1.Rows[rowIndex].Cells[
0
].Text.ToString();
string
sql_del
=
"
刪除的sql語句
"
;
//
執行刪除操作
}
}
转载于:https://www.cnblogs.com/lairdchen/archive/2008/06/05/1214247.html