private void Page_Load(object sender, System.EventArgs e)
{
if(!PageIspostBack)
{
Label1.Text=Request.QueryString["id"];
string newsid=Request.QueryString["ID"];
String strConnection=ConfigurationSettings.AppSettings["news"];
SqlConnection myConnection = new SqlConnection(strConnection); SqlCommand myCommand=new SqlCommand("SELECT * FROM contents WHERE ID="+newsid,myConnection);
myConnection.Open();
SqlDataReader dr=myCommand.ExecuteReader();
dr.Read();
TextBox2.Text=dr["biaoti"].ToString();
TextBox3.Text=dr["neirong"].ToString();
TextBox4.Text= dr["zuozhe"].ToString();
myConnection.Close(); }
}
{
if(!PageIspostBack)
{
Label1.Text=Request.QueryString["id"];
string newsid=Request.QueryString["ID"];
String strConnection=ConfigurationSettings.AppSettings["news"];
SqlConnection myConnection = new SqlConnection(strConnection); SqlCommand myCommand=new SqlCommand("SELECT * FROM contents WHERE ID="+newsid,myConnection);
myConnection.Open();
SqlDataReader dr=myCommand.ExecuteReader();
dr.Read();
TextBox2.Text=dr["biaoti"].ToString();
TextBox3.Text=dr["neirong"].ToString();
TextBox4.Text= dr["zuozhe"].ToString();
myConnection.Close(); }
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
//你的代码
}
}