我在 c# 中使用 asp.net,我的 aspx 代码如下所示
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<asp:Panel ID="panel1" runat="server">
<table><tr><td><asp:Label ID="Label2" runat="server" Font-Bold="True"
Font-Underline="True"></asp:Label></td></tr>
<tr> <td>
<asp:Button ID="btnsubmit" runat="server" Text="Submit" BackColor="#993300"
ForeColor="White" onclick="btnsubmit_Click" /></td>
<td>
<asp:Button ID="btnlogout" runat="server" Text="Logout" BackColor="#993300"
ForeColor="White" onclick="btnlogout_Click" />
</td>
</tr>
</table>
现在这是我的 C# 代码
cmd.CommandText = "update TrackingFaculty_det SET Type=@Type WHERE (FID=@FID) and DATEDIFF(d,TrackingFaculty_det.LastUpdateDate,GETDATE())>60";
提交按钮中存在,只要上述查询为真并执行,我就需要显示提交按钮,否则我不需要显示提交按钮
protected void btnsubmit_Click(object sender, EventArgs e)
{
string type = "c";
string FID = Session["FID"].ToString();
SqlConnection cn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
//int str_diff = Convert.ToInt32(ConfigurationManager.AppSettings["Difference"]);
cn.ConnectionString = @"Data Source=BOPSERVER;Initial Catalog=Project;Integrated Security=True";
cn.Open();
cmd.CommandText = *"update TrackingFaculty_det SET Type=@Type WHERE (FID=@FID) and DATEDIFF(d,TrackingFaculty_det.LastUpdateDate,GETDATE())>60*";
cmd.Connection = cn;
cmd.Parameters.Add("@FID",SqlDbType.VarChar,10);
cmd.Parameters["@FID"].Value = FID;
cmd.Parameters.Add("@Type", SqlDbType.VarChar, 1);
cmd.Parameters["@Type"].Value = type;
cmd.ExecuteNonQuery();
cn.Close();
Response.Redirect("~/Faculty/Personaldet.aspx");
}
protected void btnlogout_Click(object sender, EventArgs e)
{
Response.Redirect(@"~\home.aspx");
}
此图像应仅在update TrackingFaculty_det SET Type=@Type WHERE (FID=@FID) and DATEDIFF(d,TrackingFaculty_det.LastUpdateDate,GETDATE())>60"
执行时显示