我能够正确访问网格中的每个列/行组合,第1列除外。它始终返回空白。以下是我尝试的4种不同方式,它们都运行,但都返回空白。
def a():
result = b()
return result
a() # Call `a` before `b` has been defined.
def b():
return 'foo'
所以我想获取列用户ID
protected void userListGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Display") //switch to update user mode
{
int rowIndex = Convert.ToInt32(e.CommandArgument);
string Username = userListGrid.Rows[rowIndex].Cells[0].Text;
// LinkButton Link = userListGrid.HeaderRow.Cells[0].Controls[0] as LinkButton;
// string Username3 = Link.Text;
string Username4 = userListGrid.Rows[rowIndex].Cells[0].Text.ToString();
GridViewRow selectedRow = userListGrid.Rows[rowIndex];
TableCell lastNameCell = selectedRow.Cells[0];
string lastName = lastNameCell.Text;
List<CustomUserRecord> userRoleList = GetUserList(Username);
}
}
答案 0 :(得分:0)
我最终这样做了。可能会得到帮助,但我没有意识到这是一个Linkbutton对不起所有,谢谢你的帮助。
int rowIndex = Convert.ToInt32(e.CommandArgument);
LinkButton Link = (LinkButton)userListGrid.Rows[rowIndex].Cells[0].Controls[0] ;
string Username = Link.Text;