Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > How to add color to dropdownlist based on value from SQL Query Statement.

Reply
Thread Tools

How to add color to dropdownlist based on value from SQL Query Statement.

 
 
Rob
Guest
Posts: n/a
 
      01-26-2004
I want to be able to color code my dropdown list based on the status
of the users within the list. I have a SQL Query (stored Procedure)
that return the following data. (UserID, UserName, Status).

I bind the data like this from returning the data from a
SqlDataReader:

' dropdownlisting of all users
With UserList
.DataSource = GetUsersDropDown()
.DataTextField = "vcUserName"
.DataValueField = "vcUserID"
.DataBind()
.Items.Insert(0, "-- Select a User --")
.SelectedIndex = 0
End With

The GetUsersDropDown Function:

Public Function GetUsersDropDown() As SqlDataReader
Dim dr As SqlDataReader
Dim strConn = New
SqlConnection(HttpContext.Current.Application("str Conn"))
Dim cmdSelect = New SqlCommand("spSOCSRListX", strConn)
cmdSelect.CommandType = CommandType.StoredProcedure
strConn.Open()
dr = cmdSelect.ExecuteReader()
Return dr
strConn.Close()
End Function



The Function returns data like (10, Joe Burns, 1). I want to be able
to identify the status (3rd column) or the user and based on the
results (1-active, 0-inactive). Color the dropdown item a either red
or white.

Please help Im getting desperate....

Many Thanks
 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      01-26-2004
You cannot color the dropdown item conditionally. There is a hack to allow
you to do this. If you care, you can replace the dropdown with a select tag.
That will allow you to customize the options somewhat.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Rob" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> I want to be able to color code my dropdown list based on the status
> of the users within the list. I have a SQL Query (stored Procedure)
> that return the following data. (UserID, UserName, Status).
>
> I bind the data like this from returning the data from a
> SqlDataReader:
>
> ' dropdownlisting of all users
> With UserList
> .DataSource = GetUsersDropDown()
> .DataTextField = "vcUserName"
> .DataValueField = "vcUserID"
> .DataBind()
> .Items.Insert(0, "-- Select a User --")
> .SelectedIndex = 0
> End With
>
> The GetUsersDropDown Function:
>
> Public Function GetUsersDropDown() As SqlDataReader
> Dim dr As SqlDataReader
> Dim strConn = New
> SqlConnection(HttpContext.Current.Application("str Conn"))
> Dim cmdSelect = New SqlCommand("spSOCSRListX", strConn)
> cmdSelect.CommandType = CommandType.StoredProcedure
> strConn.Open()
> dr = cmdSelect.ExecuteReader()
> Return dr
> strConn.Close()
> End Function
>
>
>
> The Function returns data like (10, Joe Burns, 1). I want to be able
> to identify the status (3rd column) or the user and based on the
> results (1-active, 0-inactive). Color the dropdown item a either red
> or white.
>
> Please help Im getting desperate....
>
> Many Thanks



 
Reply With Quote
 
 
 
 
Eran Amitai
Guest
Posts: n/a
 
      01-27-2004
Rob,

I don't believe there's any way to color items in a dropdownlist. If this is
really important to you you could implement an input box with a drop button
that drops down an IFrame or a positioned HTML table, but that's a lot of
work.

Eran

"Rob" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> I want to be able to color code my dropdown list based on the status
> of the users within the list. I have a SQL Query (stored Procedure)
> that return the following data. (UserID, UserName, Status).
>
> I bind the data like this from returning the data from a
> SqlDataReader:
>
> ' dropdownlisting of all users
> With UserList
> .DataSource = GetUsersDropDown()
> .DataTextField = "vcUserName"
> .DataValueField = "vcUserID"
> .DataBind()
> .Items.Insert(0, "-- Select a User --")
> .SelectedIndex = 0
> End With
>
> The GetUsersDropDown Function:
>
> Public Function GetUsersDropDown() As SqlDataReader
> Dim dr As SqlDataReader
> Dim strConn = New
> SqlConnection(HttpContext.Current.Application("str Conn"))
> Dim cmdSelect = New SqlCommand("spSOCSRListX", strConn)
> cmdSelect.CommandType = CommandType.StoredProcedure
> strConn.Open()
> dr = cmdSelect.ExecuteReader()
> Return dr
> strConn.Close()
> End Function
>
>
>
> The Function returns data like (10, Joe Burns, 1). I want to be able
> to identify the status (3rd column) or the user and based on the
> results (1-active, 0-inactive). Color the dropdown item a either red
> or white.
>
> Please help Im getting desperate....
>
> Many Thanks



 
Reply With Quote
 
 
 
Reply

Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Changing font color from current font color to black color Kamaljeet Saini Ruby 0 02-13-2009 04:58 PM
file system -based website vs query string based website Boris Twila ASP .Net 0 11-14-2006 07:50 PM
Build dynamic sql query for JSTL <sql:query> Anonymous Java 0 10-13-2005 10:01 PM
how to Add different controls(textBox,DropDownList or some ) in the same column,based upon the value in the previous column (Say second Colum which contain dropdown with some values) ? Balaji ASP .Net Datagrid Control 0 07-07-2003 08:32 AM



Advertisments