Tuesday, October 14, 2008

Difference between ASP.NET and windows form Drop down list/Combo box

There is difference between ASP.NET and windows form Drop down list/Combo box.

In ASP.NET drop down list, while adding items into drop down list, we can assign/add only List Item or string into dropdown list (dropdownname.Items.add)

In Window Combo box, we can assign/add object into controls.

So there might be limitation if we want to add Object into ASP.NET drop down list item by items.

If we are going to add ListItems in ASP.Net Dropdown by
Listitem itm = new ListItem and add that drpobject.Items.add(itm)

And if we are going to select particular item by drpobject.Items[1].selected = true

We will get error like "Multiple Items cannot select".

So if we do not want this item we have to add items like drpobject.items.add(new listitm(Displaytext,Value)) and we want to select some other values then we can also use
dropdown.clearselection() method.

No comments:

Post a Comment