Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 19, 2012 01:48 PM by Sir Codalot
Feb 13, 2012 07:21 PM|LINK
I have a table on my page. The first column contains checkboxes for each row of data. The other columns are bound to my database. I need to run an SQL statement on the rows that are checked without changing data in rows that aren't checked. Here's my table:
have a drop-down list that allows the user to determine which SQL statement will be run. Here's the code in the If (IsPost) block:
foreach (var row in db.Query(selectTable1))
What happens: If all rows are checked, the statement is applied to the data n times, where n = number of data rows. If some rows are checked, I get the same result (n times on checked and unchecked rows). If no rows are checked, no rows are updated.
I need it to update only the checked rows. I would really appreciate your help on this. Thanks!
Feb 13, 2012 08:34 PM|LINK
I think that isn't so easy accomplish your goals.
You should distinguish any checkbox with an id that links it to an record's id, e.g.
<input type="checkbox" id="@row.Id" name="checkbox" />
and then examine the checkboxes extracting those checked and executing the sql statements against the linked records.
At this link
http://msdn.microsoft.com/en-us/library/hh145668(v=vs.99).aspx#sec9 you can find a lesson that explains just this procedure.
Feb 19, 2012 01:48 PM|LINK
I was able to adapt the example in the lesson suggested by GmGregori and now it works. Thanks a lot!!!