view 取某行某列的值
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語句";
//執行刪除操作
}
}
{
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語句";
//執行刪除操作
}
}


浙公网安备 33010602011771号