| Author: shilpa 17 Apr 2007 | Member Level: Silver | Rating: 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 2007 | Member Level: Silver | Rating: 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 2007 | Member Level: Silver | Rating: 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 2007 | Member Level: Silver | Rating: 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
|