C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Plz answer


Posted Date: 17 Apr 2007      Total Responses: 4

Posted By: manimegalai       Member Level: Silver     Points: 2


hi,

if i use
ListBox1.Attributes.Add("style", "color:blue")
it is working good
but if i use like
ListBox1.Items(2).Attributes.Add("style", "color:blue") it is not working




Responses

Author: shilpa    17 Apr 2007Member Level: SilverRating:     Points: 2
Hi megalai,


Becox u r assinging alternating item style for a ListBox

Dim i As Integer

For i = 0 To lstCompanies.Items.Count - 1 Step 2

lstCompanies.Items(i).Attributes.Add("style", "background-color: red")

Next
still doubt contact shilpaeee2004@yahoo.co.in


best of luck for ur bright future

Keep smiling
Shilpa


Author: manimegalai    17 Apr 2007Member Level: SilverRating:     Points: 2
hi shilpa

i didnt use alternativeitemstyle.
following is my coding. but i couldn't see any colour.
If Not IsPostBack Then
con = New SqlConnection("server=localhost;uid=sa;pwd=;database=northwind;")
da = New SqlDataAdapter("select * from products", con)
ds = New DataSet
da.Fill(ds, "All Tables")
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
ListBox1.Items.Add(New ListItem(ds.Tables(0).Rows(i)("UnitPrice"), ds.Tables(0).Rows(i)("productid")))
If ds.Tables(0).Rows(i)("UnitPrice") <= 20 Then
ListBox1.Items(i).Attributes.Add("style", "background-color:blue")
Else
ListBox1.Items(i).Attributes.Add("style", "background-color:green")
End If
Next

End If



Author: shilpa    17 Apr 2007Member Level: SilverRating:     Points: 2
In ur coding change the followings i wrote bleow then u try. Better u send any doubts to my id shilpaeee2004@yahoo.co.in

* use "new" instead of "New"


* da.Fill(ds, "All Tables")

In above the All Tables is optional

so give like this

da.Fill(ds)--its enough


*For i = 0 To ds.Tables(0).Rows.Count - 1

use like this ----> For i = 0 To ds.Tables(0).Rows.Count - 1 Step 2


************ still problem???.Better u go here megalai.use ListBox1 instead of DropDownlist





DropDownListID.Items(0).Attributes("style") = "background-color:red;"
DropDownListID.Items(1).Attributes("style") = "background-color:green;"
DropDownListID.Items(2).Attributes("style") = "background-color:blue;"

***********************************




f Not IsPostBack Then
con = New SqlConnection("server=localhost;uid=sa;pwd=;database=northwind;")
da = New SqlDataAdapter("select * from products", con)
ds = New DataSet
da.Fill(ds, "All Tables")
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
ListBox1.Items.Add(New ListItem(ds.Tables(0).Rows(i)("UnitPrice"), ds.Tables(0).Rows(i)("productid")))
If ds.Tables(0).Rows(i)("UnitPrice") <= 20 Then
ListBox1.Items(i).Attributes.Add("style", "background-color:blue")
Else
ListBox1.Items(i).Attributes.Add("style", "background-color:green")
End If
Next

End If


Author: shilpa    17 Apr 2007Member Level: SilverRating:     Points: 2
Kindly go to the given below... it may help u lot.



In da.fill(ds,"Alltable")-----> here u have to give same table name which u gave in the select command.

http://www.c-sharpcorner.com/UploadFile/sd_patel/DropDownListBox11222005064123AM/DropDownListBox.aspx


Post Reply
You must Sign In to post a response.
Next : Problem with Export to EXCEL when the webform contains images.
Previous : how i can add tool tip and 3d format in owc pie chart?
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use