Solved

bind dropdown if statement

Posted on 2010-09-20
4
310 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now