GridView Page1 CodeBehinde1:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
bool Customs_Clearance = GridView1.SelectedRow.Cells[23].Text;
}
Session["customs_Clearance"] = Customs_Clearance;
第 2 页显示会话 GridView 数据代码隐藏:复选框
CheckCustomClearance.Text=Session ["customs_Clearance"].ToString();
根据您的情况使用以下代码。我假设索引为 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");
}
}