使按钮可见给脚本错误

时间:2019-06-15 08:31:08

标签: c# asp.net gridview

我有一个gridview,当我在GridView中选择一行时,将打开包含该行数据的详细信息视图。我只想在表格中有输入日期时显示提交按钮,但这样做时出现脚本错误

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
  DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);

  BindDetailsView();
  Button1.Visible = true;
  Button1.Text = "Edit";
con.Open();
string fin_dt = "select vendor_creation_req.ucs_entry_dt from 
vendor_creation_req where req_no='" + GridView1.SelectedValue + "'";
OleDbCommand cmd = new OleDbCommand(fin_dt, con);
OleDbDataReader dr = cmd.ExecuteReader();
dr.Read();


if (dr.HasRows && dr["ucs_entry_dt"] == DBNull.Value)
{
 submit.Visible = false;
 }
 else if (dr.HasRows && dr["ucs_entry_dt"] != DBNull.Value)
{
submit.Visible = true;
}
dr.Close();
con.Close();
BindGrid();
GridView1.DataBind();
}

0 个答案:

没有答案