2015-12-13 46 views
0
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 
{ 
    Label lblEmpID = (Label)GridView1.Rows[e.RowIndex].FindControl("Label1"); //This is Table Id load on Label1 

    conn.Open(); 

    string cmdstr = "delete from LUMHS_CHALLAN_FEE where [email protected]"; 

    SqlCommand cmd = new SqlCommand(cmdstr, conn); 

    cmd.Parameters.AddWithValue("@ID", lblEmpID.Text); 

    cmd.ExecuteNonQuery(); 

    conn.Close(); 

    ShowStudentInfo(); /back to load Grid view Function 
} 

我想從GridView中刪除行,我寫了這個代碼,但行不能刪除,請幫我刪除行從GridView的在asp.net

回答

0

是您的ID整數或字符串? 如果它的整數嘗試convert.toInt32(lblEmpID.Text);請