将数据输入所有文本框后,单击提交按钮后,它不会立即显示在datagridview中,我需要重新打开表单才能看到新插入的行.要刷新什么代码?
跟着@ user3222297代码.通过添加grdPatient.Update(); 和grdPatient.Refresh(); 单击确定插入成功后仍然无法刷新.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
namespace GRP_02_03_SACP
{
public partial class patient : Form
{
// Data Table to store employee data
DataTable Patient = new DataTable();
// Keeps track of which row in Gridview
// is selected
DataGridViewRow currentRow = null;
SqlDataAdapter PatientAdapter;
public patient()
{
InitializeComponent();
}
private void btnSubmit_Click(object sender, EventArgs e)
{
if (btnSubmit.Text == "Clear") …Run Code Online (Sandbox Code Playgroud) 因为我使用html按钮和文本框登录,我必须在源代码中的javascript中执行代码,以便执行后面的代码.无论我使用管理员和123的正确用户名和密码登录并单击登录按钮,或者我没有输入任何内容并单击登录按钮,它总是将我重定向到ResultDetails.aspx.这意味着登录失败.如果它将我重定向到Search.aspx,则会通过登录.怎么了?即使我将.Value更改为.Text,它仍然是相同的效果

我的源代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
</style>
<link rel="stylesheet" type="text/css" href="stylesheets/loginstyle.css" />
<script language="javascript" type="text/javascript">
// <![CDATA[
function Button1_onclick() {
if (txtUserName.Value == "Admin" && txtPassword.Value == "123") {
//Login as Hardcoded User
//Do your stuff
window.location.assign("Search.aspx")
}
else {
window.location.assign("ResultDetails.aspx")
}
}
// ]]>
</script>
</head>
<body>
<div id="wrapper">
<form name="login-form" class="login-form" action="" method="post">
<div class="header">
<h1>Login Form</h1>
<span>Fill out the …Run Code Online (Sandbox Code Playgroud) c# ×2
asp.net ×1
button ×1
code-behind ×1
datagridview ×1
html ×1
insert ×1
login ×1
refresh ×1