How do i add Attributes to System.Web.UI.WebControls.ListItem

M

Murali Inguva

Hi,
I tried to add attributes to List Item. The I am trying to add that list
item to dropDown
I dont know why the values are not coming. My code goes some thing like
this.
lst = new System.Web.UI.WebControls.ListItem();

lst.Attributes.Add("defaultAmount", item.defaultAmount.ToString());

lst.Attributes.AddAttributes();

lst.Text= item.itemDescription + " -- " + item.defaultAmount.ToString("c") ;

lst.Value=item.itemId.ToString();

cboItems.Items.Add(lst);



Please help me
 
N

Natty Gur

Hi,

it shoulb like that :
ListItem oli = new ListItem ("text","value");
this.ListBox1.Items.Add (oli);

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
 
N

Natty Gur

Hi,

I see, you need to create your own listbox derived from ListBox and
implement it. this task is not trivial, I suggest you put your hands on
"Developing Microsoft ASP.NET Server Controls and Components "
By Nikhil Kothari, Vandana Datje
Publisher : Microsoft Press
Pub Date : September 28, 2002
ISBN : 0-7356-1582-9.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top