Saturday

Command button in a Gridview

Suppose you are displaying records in a gridview and would like to create a command button where you click on and send an email to the memberID for example.

In case you are not displaying the memberID, you should use the following syntax for doing the job:

if (e.CommandName.ToString() == "cmdContact")
{
int MemberID = (int)GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value;

//then do something with the memberID value.

No comments: