Solved

bind dropdown if statement

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

861 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