Solved

bind dropdown if statement

Posted on 2010-09-20
4
317 Views
Last Modified: 2012-06-27
Hello,

I'm trying to do this and it errors with  Input string was not in a correct format

        Dim i As Integer
        For i = 0 To surveyNameDropdown.Items.Count - 1
            If ds.Tables(0).Columns("surveyActive").ColumnName = True Then
                surveyNameDropdown.Items(i).Attributes.Add("style", "color:Red".ToString())
            End If

Column in database called surveyActive with the data type set as  bit

Thanks in advance..
0
Comment
Question by:GrantBailey
  • 2
4 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 33718611
try
Dim i As Integer
        For i = 0 To surveyNameDropdown.Items.Count - 1
            If ds.Tables(0).Columns("surveyActive").ColumnName = 1 Then
                surveyNameDropdown.Items(i).Attributes.Add("style", "color:Red".ToString())
            End If

Open in new window

0
 
LVL 35

Expert Comment

by:YZlat
ID: 33718619
if data type is bit, then use 1 or 0 instead of true or false
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 250 total points
ID: 33718649
What exactly you want to compare by: ds.Tables(0).Columns("surveyActive").ColumnName = True

If you want to compare it to the value of surveyActive then you will have to loop through the row and then get the column value like:
Convert.ToBoolean(ds.Tables(0).Rows(0)(1) == true
'this is getting value of first row second column.
0
 

Author Closing Comment

by:GrantBailey
ID: 33832651
Thanks again guru_sami.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Split in Javascript 5 39
Signal R -send data to client: only if they are allowed to see it ? 1 52
IIS Authorization for Web Service 2 46
asp day pilot 3 19
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question