我在我的項目中有這個模塊,其中有2個gridviews。一個用於Main MenuModule,另一個用於子菜單。我創建了一個List,這樣當我的Main Menu Module上的一行被選中並且它有一個對應的子菜單時,它將顯示在SubMenu Gridview上。將列表添加到會話中
我的問題是如何把這個列表到會話,以便我,當我瀏覽到另一個頁面,然後回到這個頁面,子菜單的GridView依然存在。
這是我的代碼列表。
protected void cbxSelect_CheckedChanged(object sender, EventArgs e)
{
SubMenuGrid.DataSource = null;
SubMenuGrid.DataBind();
Business.SubMenuModules sub = new Business.SubMenuModules();
List<oSubList> oList = new List<oSubList>();
int counter = 0;
foreach (GridViewRow nRow in gvModuleList.Rows)
{
Int32 intModID = Convert.ToInt32(nRow.Cells[0].Text);
CheckBox chkBx = (CheckBox)nRow.FindControl("cbxSelect");
if (chkBx.Checked == true)
{
counter = counter + 1;
var oModList = sub.GetAllMenuPerModuleID(intModID);
if (oModList.Count > 0)
{
foreach (var rec in oModList)
{
oSubList olist = new oSubList
{
ID = rec.ID,
ModuleID = rec.ModuleID,
Submenu = rec.Submenu,
Description = rec.Description
};
oList.Add(olist);
}
SubMenuGrid.DataSource = oList;
SubMenuGrid.DataBind();
}
}
爲什麼你想在會議上?你不想保存更改嗎? –
他去與狀態管理bcoz,值可以將網頁的過期後也被保留.. – Sasidharan
我不想把它保存在我的數據庫呢,我只是想臨時存儲它,這樣,當我在提交前返回到該頁面,我可以看到我的子菜單中的GridView .. – theNoobie