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語句";
               
//執行刪除操作
            }
       }

posted @ 2008-06-05 12:21  Laird  阅读(190)  评论(0编辑  收藏  举报