Click here to Skip to main content
15,897,371 members

Comments by Ansari Zaiba (Top 3 by date)

Ansari Zaiba 16-Feb-13 6:07am View    
here is the full codes of my webform.......
public partial class subjectmaster : System.Web.UI.Page
{
string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\WebSite22\\quiz.mdb";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
String query = "Select * from SubjectMaster";

OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = query;
cmd.Connection = MyConn;
OleDbDataAdapter da = new OleDbDataAdapter();

da.SelectCommand = cmd;
DataSet ds = new DataSet();

da.Fill(ds);

gvSubject.DataSource = ds.Tables[0];
gvSubject.DataBind();
// funddlBind();

}

}
protected void btnsubmit_Click(object sender, EventArgs e)
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
String strQuery = "insert into SubjectMaster(Subjectname,Totalmarks,Passingmarks)values('";

strQuery += txtSubject.Text + "','" + txtMarks.Text + "', '" + txtPassing.Text + "')";
OleDbCommand cmd = new OleDbCommand(strQuery, MyConn);
cmd.ExecuteNonQuery();

MyConn.Close();

Response.Write("<script language=Javascript> alert('Data Inserted')</script>");
funGridBind();
funClear();
}
protected void gvSubject_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.ToolTip = "Click to select row";
e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.gvSubject, "Select$" + e.Row.RowIndex);
}


}
protected void gvSubject_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = gvSubject.SelectedRow;

if (Convert.ToString(row.Cells[0].Text).Trim() == " ")
{
txtSubject.Text = "";
}
else
{
txtSubject.Text = Convert.ToString(row.Cells[0].Text).Trim();
//txtPartCodeTemp.Text = Convert.ToString(row.Cells[0].Text).Trim();
}

if (Convert.ToString(row.Cells[1].Text).Trim() == " ")
{
txtMarks.Text = "";
}
else
{
txtMarks.Text = Convert.ToString(row.Cells[1].Text).Trim();
//txtPartCodeTemp.Text = Convert.ToString(row.Cells[0].Text).Trim();
}
if (Convert.ToString(row.Cells[2].Text).Trim() == " ")
{
txtPassing.Text = "";
}
else
{
txtPassing.Text = Convert.ToString(row.Cells[2].Text).Trim();
//txtPartCodeTemp.Text = Convert.ToString(row.Cells[0].Text).Trim();
}
txtId.Text = row.Cells[3].Text;


}
protected void btnUpdate_Click(object sender, EventArgs e)
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();

String strQuery = "update SubjectMaster set Subjectname='"+ txtSubject.Text +"', Totalmarks="+ Convert.ToInt32(txtMarks.Text)+" , Passingmarks="+ Convert.ToInt32(txtPassing.Text) + " where ID=" +Convert.ToInt32(txtId.Text);

OleDbCommand cmd = new OleDbCommand(strQuery, MyConn);
cmd.ExecuteNonQuery();
MyConn.Close();

Response.Write("<script language=Javascript> alert('Data Updated')</script>");
funGridBind();
funClear();

}
protected void funGridBind()
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
string query = "Select * from SubjectMaster ";

OleDbCom
Ansari Zaiba 16-Feb-13 6:07am View    
here is the full codes of my webform.......
public partial class subjectmaster : System.Web.UI.Page
{
string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\WebSite22\\quiz.mdb";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
String query = "Select * from SubjectMaster";

OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = query;
cmd.Connection = MyConn;
OleDbDataAdapter da = new OleDbDataAdapter();

da.SelectCommand = cmd;
DataSet ds = new DataSet();

da.Fill(ds);

gvSubject.DataSource = ds.Tables[0];
gvSubject.DataBind();
// funddlBind();

}

}
protected void btnsubmit_Click(object sender, EventArgs e)
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
String strQuery = "insert into SubjectMaster(Subjectname,Totalmarks,Passingmarks)values('";

strQuery += txtSubject.Text + "','" + txtMarks.Text + "', '" + txtPassing.Text + "')";
OleDbCommand cmd = new OleDbCommand(strQuery, MyConn);
cmd.ExecuteNonQuery();

MyConn.Close();

Response.Write("<script language=Javascript> alert('Data Inserted')</script>");
funGridBind();
funClear();
}
protected void gvSubject_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.ToolTip = "Click to select row";
e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.gvSubject, "Select$" + e.Row.RowIndex);
}


}
protected void gvSubject_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = gvSubject.SelectedRow;

if (Convert.ToString(row.Cells[0].Text).Trim() == " ")
{
txtSubject.Text = "";
}
else
{
txtSubject.Text = Convert.ToString(row.Cells[0].Text).Trim();
//txtPartCodeTemp.Text = Convert.ToString(row.Cells[0].Text).Trim();
}

if (Convert.ToString(row.Cells[1].Text).Trim() == " ")
{
txtMarks.Text = "";
}
else
{
txtMarks.Text = Convert.ToString(row.Cells[1].Text).Trim();
//txtPartCodeTemp.Text = Convert.ToString(row.Cells[0].Text).Trim();
}
if (Convert.ToString(row.Cells[2].Text).Trim() == " ")
{
txtPassing.Text = "";
}
else
{
txtPassing.Text = Convert.ToString(row.Cells[2].Text).Trim();
//txtPartCodeTemp.Text = Convert.ToString(row.Cells[0].Text).Trim();
}
txtId.Text = row.Cells[3].Text;


}
protected void btnUpdate_Click(object sender, EventArgs e)
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();

String strQuery = "update SubjectMaster set Subjectname='"+ txtSubject.Text +"', Totalmarks="+ Convert.ToInt32(txtMarks.Text)+" , Passingmarks="+ Convert.ToInt32(txtPassing.Text) + " where ID=" +Convert.ToInt32(txtId.Text);

OleDbCommand cmd = new OleDbCommand(strQuery, MyConn);
cmd.ExecuteNonQuery();
MyConn.Close();

Response.Write("<script language=Javascript> alert('Data Updated')</script>");
funGridBind();
funClear();

}
protected void funGridBind()
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
string query = "Select * from SubjectMaster ";

OleDbCom
Ansari Zaiba 16-Feb-13 5:56am View    
Deleted
here is the full codes of my webform.......
public partial class subjectmaster : System.Web.UI.Page
{
string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\WebSite22\\quiz.mdb";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
String query = "Select * from SubjectMaster";

OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = query;
cmd.Connection = MyConn;
OleDbDataAdapter da = new OleDbDataAdapter();

da.SelectCommand = cmd;
DataSet ds = new DataSet();

da.Fill(ds);

gvSubject.DataSource = ds.Tables[0];
gvSubject.DataBind();
// funddlBind();

}

}
protected void btnsubmit_Click(object sender, EventArgs e)
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
String strQuery = "insert into SubjectMaster(Subjectname,Totalmarks,Passingmarks)values('";

strQuery += txtSubject.Text + "','" + txtMarks.Text + "', '" + txtPassing.Text + "')";
OleDbCommand cmd = new OleDbCommand(strQuery, MyConn);
cmd.ExecuteNonQuery();

MyConn.Close();

Response.Write("<script language=Javascript> alert('Data Inserted')</script>");
funGridBind();
funClear();
}
protected void gvSubject_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.ToolTip = "Click to select row";
e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.gvSubject, "Select$" + e.Row.RowIndex);
}


}
protected void gvSubject_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = gvSubject.SelectedRow;

if (Convert.ToString(row.Cells[0].Text).Trim() == " ")
{
txtSubject.Text = "";
}
else
{
txtSubject.Text = Convert.ToString(row.Cells[0].Text).Trim();
//txtPartCodeTemp.Text = Convert.ToString(row.Cells[0].Text).Trim();
}

if (Convert.ToString(row.Cells[1].Text).Trim() == " ")
{
txtMarks.Text = "";
}
else
{
txtMarks.Text = Convert.ToString(row.Cells[1].Text).Trim();
//txtPartCodeTemp.Text = Convert.ToString(row.Cells[0].Text).Trim();
}
if (Convert.ToString(row.Cells[2].Text).Trim() == " ")
{
txtPassing.Text = "";
}
else
{
txtPassing.Text = Convert.ToString(row.Cells[2].Text).Trim();
//txtPartCodeTemp.Text = Convert.ToString(row.Cells[0].Text).Trim();
}
txtId.Text = row.Cells[3].Text;


}
protected void btnUpdate_Click(object sender, EventArgs e)
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();

String strQuery = "update SubjectMaster set Subjectname='"+ txtSubject.Text +"', Totalmarks="+ Convert.ToInt32(txtMarks.Text)+" , Passingmarks="+ Convert.ToInt32(txtPassing.Text) + " where ID=" +Convert.ToInt32(txtId.Text);

OleDbCommand cmd = new OleDbCommand(strQuery, MyConn);
cmd.ExecuteNonQuery();
MyConn.Close();

Response.Write("<script language=Javascript> alert('Data Updated')</script>");
funGridBind();
funClear();

}
protected void funGridBind()
{
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
string query = "Select * from SubjectMaster ";

OleDbCom