Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 02-23-2007, 10:41 AM   #1
In Runtime
Daeva's Avatar
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default ASP CheckBox problem

I have a solution to this problem already, but it's not pretty and i'd like to see if there is a better one. Here is the problem:

I have a database, and in that database there is a table called Servers.
This is a Microsoft SQL Server Express Database(Not enterprise level).
The database contains the following fields (this is not a complete list of all fields):
serverID int identity,
networkID int not null,
customerID int not null,
serverName varchar(25) not null,

And these are the fields in question

PDC tinyint,
BDC tinyint,
EXCH tinyint,
SQL tinyint,
WWW tinyint,
FTP tinyint,
WTS tinyint,
DHCP tinyint,
DNS tinyint,
WINS tinyint,
POP tinyint,
SMTP tinyint,
PPTP tinyint,
isBackup tinyint.

Now I have a formView control on my asp.net page, the control has a readOnly and Edit mode, no insert. Those fields are representative of boolean values, and when adding a server to the database I just use a for loop to populate the various different values:

Dim x As Integer = New Integer
Dim y As Integer = 17
Dim myVar As Integer = New Integer
For x = 0 To 13 Step 1
If CType(Me.addServerFormView.FindControl("infoCheckBoxLis t"), CheckBoxList).Items(x).Selected() = True Then
myVar = 1
myVar = 0
End If
Me.SqlDataSource1.InsertParameters(y).DefaultValue() = myVar
y = y + 1

This is where SqlDataSource1's insert parameters for the afore mentioned database fields starts at field 17 and there are 13 values.

That works fine, now the question is, when outputting these values, I have to systematically(with a for loop) check to see if the value is 0 or 1, and if it is, display the proper text corresponding to the field name. if 1 then the server has that capability and display the text, and if 0 then don't display the text but still pass the value 0 for the update from read Only mode.

Sorry, this is a lot to articulate at once, I may need to clarify some things.
Now the problem is that all of this required a lot of code, and looking through the page. For those not very familiar with vb, the FindControl() Method is similar to javascript's getElementById(), only you have to adhere to stricter XML standards as far as child vs root elements go. Then to output the values to the read only, I have invisible <asp>'s that get the value, be it 0 or 1. I then have code that says when these are done loading, get the values, and change the text in these textboxes to the field name, be it PDC(Primary Data Server), or BDC(Backup Data Server) just to name a few. That is a pretty messy way of getting things done, and it's not 100% reliable i've found out. What can I do?
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
Daeva is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 10:00 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0