Currently using a webgrid
@{
var DB = Database.Open("CHAVI");
var grid = new WebGrid(DB.Query("SELECT [FileTrackingTag], FileID FROM (SELECT [FileTrackingTag], FileID, ROW_NUMBER() OVER (PARTITION BY [FileTrackingTag] ORDER BY FileID) rn FROM [dbo].[MasterSequence]) t WHERE rn=1 ORDER BY [FileTrackingTag]"));
@grid.GetHtml(
tableStyle: "webgrid",
columns: grid.Columns(
grid.Column(header: "Assign? ", style: "labelcolumn",
format:
@<text><input class="check-box" id="assignChkBx" name="assignChkBx" type="checkbox" value="@item.FileTrackingTag" onchange='handleChange(this);' /></text>),
grid.Column("FileTrackingTag", "FileTrackingTag")
)
)
}
And I have a hiddenfield
@Html.HiddenFor(m => m.MyHiddenDict)
from my model
public Dictionary<string, string> MyHiddenDict = new Dictionary<string, string>();
I need a javascript function that will add or remove to the dictionary based off if the checkbox is checked or not. My first approach was to add it to a string that was comma delimited. However, I have no way of undoing it if the user unclicks the checkbox. Any suggestions?
Turns out you need to just force the user to select only from one page, otherwise you need to create a list in the sessionstate and when you call the webgrid page check off the ones you already used