Edit Course Cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class admin_EditCourse : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString["cid"] == null)
{
Response.Redirect("~/admin/ViewCourse.aspx", true);
}
string cid = Request.QueryString["cid"].ToString();
string qu = "select coursename from course where courseid=" + cid;
DataSet ds = dbase.select(qu);
if (ds != null && ds.Tables.Count == 1)
{
TextBox1.Text = ds.Tables[0].Rows[0]["coursename"].ToString();
RequiredFieldValidator1.InitialValue = TextBox1.Text;
}
lblCourseId.Text = cid;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string up = TextBox1.Text;
string qu = "update course set coursename='"+up+"' where courseid="+lblCourseId.Text;
int i = dbase.insert(qu);
if (i == 1) {
//Successful
ScriptManager.RegisterStartupScript(this, this.GetType(), "js1",
"alert('Saved Successfully!!');window.location='ViewCourse.aspx'", true);
}
else {
//Error unsuccesful
ScriptManager.RegisterStartupScript(this, this.GetType(), "js2",
"alert('Error While Saving. Try Again later');window.location='ViewCourse.aspx'", true);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("~/admin/ViewCourse.aspx");
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class admin_EditCourse : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString["cid"] == null)
{
Response.Redirect("~/admin/ViewCourse.aspx", true);
}
string cid = Request.QueryString["cid"].ToString();
string qu = "select coursename from course where courseid=" + cid;
DataSet ds = dbase.select(qu);
if (ds != null && ds.Tables.Count == 1)
{
TextBox1.Text = ds.Tables[0].Rows[0]["coursename"].ToString();
RequiredFieldValidator1.InitialValue = TextBox1.Text;
}
lblCourseId.Text = cid;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string up = TextBox1.Text;
string qu = "update course set coursename='"+up+"' where courseid="+lblCourseId.Text;
int i = dbase.insert(qu);
if (i == 1) {
//Successful
ScriptManager.RegisterStartupScript(this, this.GetType(), "js1",
"alert('Saved Successfully!!');window.location='ViewCourse.aspx'", true);
}
else {
//Error unsuccesful
ScriptManager.RegisterStartupScript(this, this.GetType(), "js2",
"alert('Error While Saving. Try Again later');window.location='ViewCourse.aspx'", true);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("~/admin/ViewCourse.aspx");
}
}
No comments:
Post a Comment