插入完后要绑定一下就可以
==================================================
插入完后是绑定一下题目说明详细见:
http://topic.csdn.net/u/20070504/19/53fff6da-b4e4-47a8-a158-2d3e10075b43.html
==================================================
插入完后是绑定一下题目说明详细见:
http://topic.csdn.net/u/20070504/19/53fff6da-b4e4-47a8-a158-2d3e10075b43.html
以上只要实现刷新页面就可以了。再就是页面载入事件不要放在 if(!Page.IsPostBack)
{
}中。
opener.location.reload();
</Script>";
HttpContext.Current.Response.Write(js);再你insert完了后用java脚本刷新窗口不就行了
.cs页。 单击保存按钮 protected void btnSaveCourse_Click(object sender, EventArgs e)
{
try
{
if (!CheckCourseNameIsExist(this.txtCourseName.Text.Trim())) return;
if (this.txtCourseName.Text == "" || this.txtCourseName.Text == string.Empty)
{
ScriptManager.RegisterStartupScript(this.Page, GetType(), "Information", Common.FormatScriptMessage("课程名不能为空!"), true);
return;
}
CourseInfo courseInfo = new CourseInfo();
CourseOperation courseOperation = new CourseOperation();
courseInfo.CourseID = Common.NewGuid();
courseInfo.CourseName = this.txtCourseName.Text.Trim();
courseInfo.ProblemNum = 0;
if (!courseOperation.InsertCourse(courseInfo)) return;
BindDataToGridView(); }
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(this.Page, GetType(), "Information", Common.FormatScriptMessage(ex.Message), true);
}
}
.aspx页 用到updatePanel
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:GridView ID="gvCourses" runat="server" SkinID="gvStandard" >
</asp:GridView>
<asp:Button ID="btnAddCourse" runat="server" OnClick="btnAddCourse_Click" Text="添加课程" />
<asp:Button ID="btnDeleteCourse" runat="server" OnClick="btnDeleteCourse_Click" Text="删除课程" /><br />
<asp:Panel ID="Panel1" runat="server" Height="50px" Visible="False" Width="125px">
<table>
<tr>
<td style="width: 59px" >
<asp:Label ID="lblCourseName" runat="server" Text="课程名:" Height="16px" Width="67px" SkinID="StandardDarkBlueW60"></asp:Label></td>
<td>
<asp:TextBox ID="txtCourseName" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:Button ID="btnSaveCourse" runat="server" OnClick="btnSaveCourse_Click" Text="保存" />
<asp:Button ID="btnCancel" runat="server" OnClick="btnCancel_Click" Text="取消" /></td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>说明:如果连接sql server 2000数据库 一切正常。连接access数据库出现这个问题,如何解决?谢谢各位回复。谢谢谢谢。
说明:如果连接sql server 2000数据库 一切正常。连接access数据库出现这个问题,如何解决?谢谢各位回复。谢谢谢谢。还有如果自己设置断点一步一步调试最后出来的页面是正确的,会实时刷新gridview.直接运行就会出问题。
{
BindDataToGridView();
}
等 级:
发表于:2007-11-22 14:19:1511楼 得分:0
数据操作完成后,调用gridview控件的databind()方法即可.
=========================================================
都有databind(),就是用sql server2000一切正常,用access就有问题
1. 检查,page_load事件中是否进行了 if(!Page.IsPostBack)判断;
2. 操作之后,重新调用,绑定gridview的方法。
1. 检查,page_load事件中是否进行了 if(!Page.IsPostBack)判断;
2. 操作之后,重新调用,绑定gridview的方法。
====================================================
用sql server2000一切正常,用access就有问题
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Page.IsPostBack) return; BindDataToGridView();
this.lblPageSubject.Text = "Welcome To The Page Of Course Setting";
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(this.Page, GetType(), "Information", Common.FormatScriptMessage(ex.Message), true);
}
}