Groups | Blog | Home
all groups > asp.net > october 2003 >

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



Murali Inguva
10/20/2003 11:05:42 PM
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

Natty Gur
10/21/2003 11:22:18 AM
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


*** Sent via Developersdex http://www.developersdex.com ***
Murali Inguva
10/21/2003 5:01:07 PM
I want to add attributes to list item



[quoted text, click to view]

Natty Gur
10/22/2003 9:02:57 AM
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


*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button