任何时候用户点击Bookmark按钮,我想将该行的ProgramID列中的数据发送到List并将其传递到另一个页面的第二个gridview。但我的第二个gridview不显示任何数据。我究竟做错了什么? 这是我的书签按钮代码:
protected void btnSelect_Click(object sender, EventArgs e)
{
Button b = (Button)sender;
GridViewRow row = (GridViewRow)b.NamingContainer;
var ProgramID = row.FindControl("lblProgramID") as Label;
string stringProgramID = ProgramID.Text;
List<string> bookmarkPrograms = new List<string>();
bookmarkPrograms.Add(stringProgramID);
Session["BookmarkProgram"] = bookmarkPrograms;
}
以下是Bookmark页面中的代码:
protected void Page_Load(object sender, EventArgs e)
{
List<string> bookMarkPrograms = (List<string>)Session["BookMarkPrograms"];
GridView1.DataSource = bookMarkPrograms;
GridView1.DataBind();
}