I have a datagridview that has a list of names and phone numbers, if you click a name it loads a form. I am trying to return the name that is clicked so that, I can load the form more quickly. I got the 3 line of this code from someone else but get errors on both e.Rowindex and e.ColumnIndex. I would think from the error this code is wrong, but the answer i got it from had a bunch of upvotes and was market correct.
Error 43 'System.Web.UI.WebControls.GridViewCommandEventArgs' does not contain a definition for 'RowIndex' and no extension method 'RowIndex' accepting a first argument of type 'System.Web.UI.WebControls.GridViewCommandEventArgs' could be found (are you missing a using directive or an assembly reference?)
protected void userListGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Display") //switch to update user mode
{
//what I am trying to do
string Username = userListGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
List<CustomUserRecord> userRoleList = GetUserList();
int idx = 0;
int.TryParse(e.CommandArgument.ToString(), out idx);
CustomUserRecord user = userRoleList[idx];
SetUpdateUserMode(user);
}
}