VB.NET - Listbox's listitem not able to preserve its value on postback?

Asked By deepi singh on 13-Jul-12 08:16 AM
 ListBox's ListItem does not preserve its attributes on postback.....

iam doing this below code when page is not postback......

ListItem lItem = new ListItem("Test1", "1");


lItem.Attributes.Add("D", "1");----------------attributes of listbox listitem not holding on postback


listbox.Items.Add(lItem);



i have two listboxes with add and remove buttons.......

In Page_Load event iam binding listitem and attributes to listbox when page is not postback.....

when user is trying to move selected item from left side listbox to right side listbox by clicking add button..at tht time page is getting postback and not able to preserve listbox listitem attributes.....

how to preserve ListBox's ListItem  attributes on postback.....

pls help me out.......
Jitendra Faye replied to deepi singh on 13-Jul-12 08:37 AM
Try to bind dropDownList like this-

protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
      {
        //Bind DropDownList here
      }

 }