如果我在GridView ButtonField中使用自己的CommandName向FormView显示某些行的详细信息,并且当我单击第一行时显示它,而对于其他行则显示它不起作用,这是什么原因?我还有其他按钮字段和命令名的列,它们对每一行都能正常工作....
protected void gvQuizes_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cnOptions")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gvTestyW.Rows[index];
if (row != null)
{
LinkButton lbtn = row.Cells[5].Controls[0] as LinkButton;
string quizID = gvTestyW.DataKeys[row.RowIndex].Value.ToString();
if (lbtn.Text == "Show")
{
lbtn.Text = "Hide";
fvOptions.Visible = true;
sdsOpcje.SelectCommand = "HERE IS SQL QUERY THAT ENDS WITH: WHERE quizes.Id=" + quizID;
}
else if (lbtn.Text == "Hide")
{
lbtn.Text = "Show";
fvOptions.Visible = false;
}
}