0
这里是我的viewstate的代码。但它只存储一个值。我需要的是它会将选定的多个值保留在复选框中。这种方法是在分页情况的gridview中保持/保留复选框的值。如何在viewstate中存储复选框值的多个值?
public void chkAssignee_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox selectBox = (CheckBox)sender;
GridViewRow myRow = (GridViewRow)selectBox.Parent.Parent; // the row
GridView myGrid = (GridView)myRow.Parent.Parent; // the gridview
string ID = myGrid.DataKeys[myRow.RowIndex].Value.ToString();
GridViewRow rowSelect = (GridViewRow)selectBox.Parent.Parent;
int a = rowSelect.RowIndex;
ViewState["id"] = ID;
}
尝试将其保存到逗号分隔字符串或东西。 – sajanyamaha
将内容保存在“List”或“Dictionary”中,并保存到“ViewState”中。 –