嗨,我想在具有特殊值的条件下禁用网格视图中的链接底部控件。例如,如果一行的计数变为 0,则该行的链接底部应该是不可见的。我应该怎么办?我应该在哪里写代码?这是我在行命令网格视图中编写的鳕鱼,但它仅适用于我将链接推到底部!但我想在加载之前将此鳕鱼应用到我的页面。请指导我
int idx = Convert.ToInt32(e.CommandArgument);
idx = idx - (GridView1.PageSize * GridView1.PageIndex);
int ID = (int)GridView1.DataKeys[idx].Value;
string connStr = ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(connStr);
SqlCommand sqlcmd = new SqlCommand();
sqlcmd = new SqlCommand("SELECT count(ID) FROM ReviwerArticle where ArticleID=@ArticleID", sqlconn);
sqlcmd.Parameters.AddWithValue("@ArticleID", ID);
sqlconn.Open();
int count = ((int)sqlcmd.ExecuteScalar());
sqlconn.Close();
if (count == 0)
{
((LinkButton)GridView1.Rows[idx].Cells[0].FindControl("LinkButton4") as LinkButton).Visible = false;
}