protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
bool Customs_Clearance = GridView1.SelectedRow.Cells[23].Text;
}
Session["customs_Clearance"] = Customs_Clearance;
和Page2哪个Show会话GridView数据代码背后: 复选框
CheckCustomClearance.Text=Session ["customs_Clearance"].ToString();
答案 0 :(得分:0)
根据您的情况使用以下代码。 我假设索引为23的列是布尔列,并显示为复选框列。
然后,您可以随时访问其他页面Session["customs_Clearance"]
。
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
//get selected row
GridRow selectedRow = GridView1.Rows[GridView1.SelectedIndex];
//check if it's a checkbox column and set Session variable, if it is
if(selectedRow.Cells[23].Controls[0] is CheckBox) {
bool isChecked = (selectedRow.Cells[23].Controls[0] as CheckBox).Checked;
Session["customs_Clearance"] = (isChecked == true ? "checked" : "unchecked");
}
}