How to delete record with datagrid?

Can you tell me how to delete record in datagrid?

Ex:
id(Invisible)           Date              Aggregate          Network            System         Application            Delete
1                          Dec 2007         100.00                 97.00               100.00           100.00                Delete
2                          Dec 2007         100.00                 90.50               88.00             100.00                Delete

The id column is invisible.
tommychiuAsked:
Who is Participating?
 
monarch_ilhanCommented:
Hi, In one way is to set ID field yo CommandArgument of Delete button. And on row command event of GridView check it to verify Delete command clicked
if(e.CommandName=="Delete")
{
 int ID=int.Parse(e.CommandArgument.ToString());
//Connect to Db and execute a sql which deletes row has ID you got from delete button command argument

//then rebind the grid view

}
0
 
mokuleCommented:
Have You tried
                this.Datagrid1.Rows.RemoveAt(0)  ?
0
 
tommychiuAuthor Commented:
How's that work? Is it will remove the record from my sql table completely?
0
 
mokuleCommented:
No it won't remove.
You need to call Update method of a TableAdapter to which Your datagrid is bind
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.