Creating a list of checkboxes using ASP.NET MVC for a table without a primary key
Long story short, the database I'm using needs to get looked at. Until that happens, I need to make do with what I've been given (I know, I should fix it..).
I have a table that get populated via an external text file. I am not sure of the exact process as I'm relatively new to the company.
The table does not have a primary key as the entire table is dumped and re-loaded every quarter when there is a new text file.
Enter ASP.NET MVC. I need to display that table with checkboxes in a grid so the user can select some rows and send it back to the server. It sounds relatively easy, but I am really not sure what to put as the value for the checkboxes as I am pretty sure I'll need to开发者_如何学Go use multiple columns to create a unique. Yep, I know, I know :).
OldTable
- Field1
- Field2
- Field3
...
- FieldN
The View
...
<input type="checkbox"
name="bunchOfStuff"
value"Field1Value,Field2Value,Field3Value"/>
...
Would something like this work? If I can create a key with a few fields, can I use those fields as the value in the checkbox? I realize my action will be a bit ugly as I'll have to split and parse each value in the array of values.
Wow, good luck with this!
I think your solution will certainly work and I can't think of a more elegant solution.
However I think you're going to be in deep trouble down the line. The thing that I would do would to be simply to put a Unique Identifer on the table that auto increments.
That shouldn't affect any of your processes or even your bulk insert application unless you insert using an ordinal field offset rather than named.
Sorry this answer isn't exactly what your looking for but the DB is just so bad that (any) answer presented I think will be equally bad.
精彩评论