Free Search Engine Submission Search Engine Submission - AddMe ASP.NET Help, ASP.NET Tutorials, ASP.NET Programming, ASP.NET Tricks

Wednesday, March 10, 2010

Update table data in asp.net c#

protected void Button1_Click(object sender, EventArgs e)

{

SqlConnection con = new SqlConnection("Connection string");

con.Open();

SqlCommand cmd=new SqlCommand("Update table1 set name='"+TextBox1.text+"' where no='"+textbox2.text+"'",con);

cmd.ExecuteNonQuery();

con.Close();

}

Insert data into database in c# .net


protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Connection string");
con.Open();
SqlCommand cmd=new SqlCommand("Insert into table1 values('"+TextBox1.text+"','"++"')",con);
cmd.ExecuteNonQuery();
con.Close();
}

Tuesday, March 9, 2010

Display date which we select in the calender


protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
Label1.Text = Calendar1.SelectedDate.ToShortDateString();
}

Display time and date in runtime in .net


protected void Page_Load(object sender, EventArgs e)
{
Response.Write(DateTime.Now.ToString());
}

How redirect onepage to another in .net


protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("nextpage.aspx");
}

Sign out code for .net
session.abdon();
response.redirect("loginpage.aspx");