62,073
社区成员
发帖
与我相关
我的任务
分享
public void RememberOldValues()//记住GridView中的选择项
{
ArrayList categoryIDList = new ArrayList();
int index = -1;
foreach (GridViewRow row in grvTaskList.Rows)
{
index = (int)grvTaskList.DataKeys[row.RowIndex].Value;
bool result = ((CheckBox)row.FindControl("chbOne")).Checked;
// Check in the Session
if (Session["grvinfo"] != null)
{
categoryIDList = (ArrayList)Session["grvinfo"];
}
if (result)
{
if (!categoryIDList.Contains(index))
{
categoryIDList.Add(index);
}
}
else
{
categoryIDList.Remove(index);
}
}
if (categoryIDList != null && categoryIDList.Count > 0)
{
Session["grvinfo"] = categoryIDList;
}
}
public void RePopulateValues()//恢复GridView中的选择项
{
ArrayList categoryIDList = (ArrayList)Session["grvinfo"];
if (categoryIDList != null && categoryIDList.Count > 0)
{
foreach (GridViewRow row in grvTaskList.Rows)
{
int index = (int)grvTaskList.DataKeys[row.RowIndex].Value;
if (categoryIDList.Contains(index))
{
CheckBox myCheckBox = (CheckBox)row.FindControl("chbOne");
myCheckBox.Checked = true;
}
}
}
}
$(document).ready(function() {
$("#checkbox1").click(function() {
if (!!$("#checkbox1").attr("checked")) {
//..
}
});
});