i make a gridview and i make a code :
delete row in gridview
this funcition use delete a row in database
and i ask how to i invoke id of each row in Gridview
to pass into this function to delete row
example : I make a another function for click button
delete row in gridview
Code:
public bool Delete(int id, out string Msg) { Msg = ""; try { SqlServerDb sql = new SqlServerDb();// library connect sql.Connect(); string cmdText = "Delete from tbl_Status where Id=@Id"; SqlParameterList paramList = new SqlParameterList(); paramList.Add("@Id", id, SqlDbType.SmallInt); sql.ExecuteNonQuery(cmdText, SqlCommandType.Text, paramList); sql.Disconnect(); return true; } catch (Exception ex) { Msg = ex.Message; return false; } }
and i ask how to i invoke id of each row in Gridview
to pass into this function to delete row
example : I make a another function for click button
Code:
protected void btn_delete_Click(object sender, EventArgs e) { TMLib.Business.AddStatus status = new AddStatus();// // i need do if( status.Delete( ?, out message); i don't know pass this value id }
Comment