隐藏或禁用下拉列表

时间:2013-10-21 19:08:24

标签: c# asp.net c#-4.0

我正在尝试隐藏行或在文档被批准一次时禁用下拉列表。 此代码执行已批准/已拒绝/待处理。现在,我希望这样做,以便当管理员批准文档一次,然后当他/她再次登录时,他们应该无法再次批准/拒绝同一文档。这是我的asp.net代码:

protected void Button1_Click(object sender, EventArgs e)
{
   string connStr = 
         ConfigurationManager.ConnectionStrings["mydms"].ConnectionString;
   SqlConnection mySQLconnection = new SqlConnection(connStr);
   if (mySQLconnection.State == ConnectionState.Closed)
   {
      mySQLconnection.Open();
   }

   foreach (GridViewRow row in GrdFileApprove.Rows)
   {
      if (row.RowType == DataControlRowType.DataRow)
      {
         DropDownList DropDownListcontrol = row.FindControl("DropDownList4") as 
            DropDownList;

         SqlCommand cmd = new SqlCommand("approveddd", mySQLconnection);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@DocID", SqlDbType.Int).Value = 
         Convert.ToInt32((row.Cells[1].Text));

         cmd.Parameters.Add("@ApproveID", SqlDbType.Int).Value = 
         Convert.ToInt32(DropDownListcontrol.SelectedValue);
         cmd.Parameters.Add("@ApproveBy", SqlDbType.VarChar, 50).Value =
            (Session["Login2"]);

         cmd.ExecuteNonQuery(); 
      }

      else
      {
         apfi.Text = "Error";
      }
   }

   if (mySQLconnection.State == ConnectionState.Open)
   {
      mySQLconnection.Close();
   }

我该怎么做?

1 个答案:

答案 0 :(得分:1)

隐藏下拉菜单:

DropDownList1.Visible = false;

禁用下拉菜单:

DropDownList1.Enabled = false;