Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
123 views
in Technique[技术] by (71.8m points)

c# - How to disable and uncheck the checkbox values from database fields..VB.NET

I have retrieved checkbox checked values & put in textbox as 1,2,3,4,5...so on ...and inserted into database ... using vb.net

Have a look at my database ..

Name               checked                Date

Sumit              3,2                    11-Dec-2010
Manish             1,5,4                  11-Dec-2010 
Dobriyal           1,2,3,4                12-Dec-2010

I want when I search for the record of 11-Dec-2010 then checkbox 1, checkbox2, checkbox3, checkbox4, checkbox5 will be unchecked and disabled for 11-Dec-2010...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Dim checked = From chosen in db.Table Where chosen.date = "11/10/2010" Select chosen.checked

Dim boxes as new List (of string)
For each item in checked
   boxes.addrange(item.split(","c))
Next

Dim BoxNums = From boxnum in boxes Distinct Select "checkbox" + Cstr(boxnum)

For Each but As CheckBox In YourForm.Controls
   For Each boxname As String In boxnums
        If but.Name = boxname Then
            but.Checked = False
            but.Enabled = False
        End If
    Next
Next

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...