主页面homepage的GridView1_RowDataBound:
程序代码:protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int typeID;
typeID = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "diaryKindId"));
string str = "";
string s = "select diaryKind from _data2 where id = " + typeID;
string strcon = ConfigurationManager.ConnectionStrings["_dataConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strcon);
con.Open();
SqlCommand cmd = new SqlCommand(s, con);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
str = sdr["diaryKind"].ToString();
}
con.Close();
Label lbl = (Label)e.Row.FindControl("Label1");
lbl.Text = str;
con.Close();
}链接的页面newpage的Page_Load:
程序代码:protected void Page_Load(object sender, EventArgs e)
{
int diary = Int32.Parse(Request.QueryString["key"].ToString());
string strcon = ConfigurationManager.ConnectionStrings["_dataConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strcon);
con.Open();
SqlCommand com = new SqlCommand("select diaryContent from _data1 where id = " + diary, con);
content = com.ExecuteScalar().ToString();
}在newpage的body中添加<%=content%>









