Solved

bind dropdown if statement

Posted on 2010-09-20
4
325 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Please explain purpose of GZIP 4 80
Easy filter aspnet 2 46
asp.net mvc 2 43
ASP.net Moving Visual Studio 2015 project to 2017 2 63
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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