public partial class managecourse : System.Web.UI.Page
{
connection c = new connection();
string s;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
detail_bind();
}
}
public void detail_bind()
{
cmd.CommandText = Select * from login;
adp.Fill(ds, "vtt");
dv.DataSource = ds.Tables["vtt"];
dv.DataBind();
}
{
cmd.CommandText = Select * from login;
adp.Fill(ds, "vtt");
dv.DataSource = ds.Tables["vtt"];
dv.DataBind();
}
protected void mode(object sender, DetailsViewModeEventArgs e)
{
if (DetailsView1.CurrentMode == DetailsViewMode.ReadOnly)
{
DetailsView1.ChangeMode(DetailsViewMode.Edit);
FileUpload fl = new FileUpload();
detail_bind();
fl = (FileUpload)DetailsView1.FindControl("FileUpload1");
}
else
{
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
detail_bind();
}
}
protected void update(object sender, DetailsViewUpdateEventArgs e)
{
TextBox t1 = new TextBox();
TextBox t2 = new TextBox();
TextBox t3 = new TextBox();
TextBox t4 = new TextBox();
TextBox t5 = new TextBox();
TextBox t6 = new TextBox();
{
if (DetailsView1.CurrentMode == DetailsViewMode.ReadOnly)
{
DetailsView1.ChangeMode(DetailsViewMode.Edit);
FileUpload fl = new FileUpload();
detail_bind();
fl = (FileUpload)DetailsView1.FindControl("FileUpload1");
}
else
{
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
detail_bind();
}
}
protected void update(object sender, DetailsViewUpdateEventArgs e)
{
TextBox t1 = new TextBox();
TextBox t2 = new TextBox();
TextBox t3 = new TextBox();
TextBox t4 = new TextBox();
TextBox t5 = new TextBox();
TextBox t6 = new TextBox();
TextBox t7 = new TextBox();
TextBox t8 = new TextBox();
TextBox t9 = new TextBox();
TextBox t10 = new TextBox();
FileUpload fl = new FileUpload();
t1 = (TextBox)DetailsView1.Rows[0].Cells[1].Controls[0];
t2 = (TextBox)DetailsView1.Rows[1].Cells[1].Controls[0];
t1 = (TextBox)DetailsView1.Rows[0].Cells[1].Controls[0];
t2 = (TextBox)DetailsView1.Rows[1].Cells[1].Controls[0];
t3 = (TextBox)DetailsView1.Rows[2].Cells[1].Controls[0];
t4 = (TextBox)DetailsView1.Rows[3].Cells[1].Controls[0];
t5 = (TextBox)DetailsView1.Rows[4].Cells[1].Controls[0];
t6 = (TextBox)DetailsView1.Rows[5].Cells[1].Controls[0];
t7 = (TextBox)DetailsView1.Rows[6].Cells[1].Controls[0];
t8 = (TextBox)DetailsView1.Rows[7].Cells[1].Controls[0];
t9 = (TextBox)DetailsView1.Rows[8].Cells[1].Controls[0];
t10 = (TextBox)DetailsView1.Rows[9].Cells[1].Controls[0];
fl = (FileUpload)DetailsView1.FindControl("FileUpload1");
s = "~//image/" + fl.FileName;
fl.SaveAs(Server.MapPath(s));
c.con.Open();
c.cmd.CommandText = "update login set uname='" + t1.Text + "',dob='" + t2.Text + "',gender='" + t3.Text+ "',addr='"+t4.Text+"'country='"+t5.Text+"',state='"+t6.Text+"',city='"+t7.Text+"', zipcode='"+t8.Text+"', phono='"+t9.Text+"' ,email='"+t10.Text+"', imgpath='"+s+"' where email='"+t10.Text+"'";
c.cmd.ExecuteNonQuery();
c.con.Close();
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
fl.SaveAs(Server.MapPath(s));
c.con.Open();
c.cmd.CommandText = "update login set uname='" + t1.Text + "',dob='" + t2.Text + "',gender='" + t3.Text+ "',addr='"+t4.Text+"'country='"+t5.Text+"',state='"+t6.Text+"',city='"+t7.Text+"', zipcode='"+t8.Text+"', phono='"+t9.Text+"' ,email='"+t10.Text+"', imgpath='"+s+"' where email='"+t10.Text+"'";
c.cmd.ExecuteNonQuery();
c.con.Close();
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
detail_bind();
}
}
protected void delete(object sender, DetailsViewDeleteEventArgs e)
{
c.con.Open();
c.cmd.CommandText = "delete from login where email='"+DetailsView1.DataKey[e.RowIndex].ToString()+"'";
c.cmd.ExecuteNonQuery();
c.con.Close();
}
c.con.Open();
c.cmd.CommandText = "delete from login where email='"+DetailsView1.DataKey[e.RowIndex].ToString()+"'";
c.cmd.ExecuteNonQuery();
c.con.Close();
}
}
No comments:
Post a Comment