I have an AjaxModalPopup that displays a list of Checkboxes (18 altogether) that represent options in my main form.
The options are stored in SQL along with the stock code they apply to, in a very simple two column table. [StockCode][Category]
I can save these options to a SQL table correctly and can verify in SQL that they are there.
What I am trying to do is retrieve them with a stored procedure and use the result to check the relevant checkboxes when the modalpopup 'pops' up. I have double checked my procedure in SQL Server Manager and it works fine, but my checkboxes won't select at all.
I would like to end up with a function that pre-selects the checkboxes so when somebody uses the feature to edit the options they don't have to try to remember what is already selected.
Code, VB.NET
Protected Sub btnEditPC_Click(sender As Object, e As System.EventArgs) Handles btnEditPC.Click
Dim dt As DataTable = SqlHelper.ExecuteDataset(System.Configuration.ConfigurationManager.AppSettings("dbConn"), "xw_GetAllFromPCBuilderCategory", "SY02053").Tables(0)
For Each row As DataRow In dt.Rows
For Each item As ListItem In chklstCat.Items
If String.Equals(row("Category"), item.Text) Then
item.Selected = True
End If
Next
Next
End Sub
My loop doesn't seem to do anything, but I can't figure out where I've gone wrong. It looks to me as though this should check each result from the data table and compare it to the text value in my checkboxes, then marking the matches?
Aucun commentaire:
Enregistrer un commentaire