Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Asp:ListBox and selectedindex

Reply
Thread Tools

Asp:ListBox and selectedindex

 
 
John Giblin
Guest
Posts: n/a
 
      11-26-2003
I have a ListBox within a repeater tag and I am trying to set the selected
value. I tried the following without success. I was also tryng to make a
method for the selectedindex but I do not know how to pass the instance of
this asp:listbox control.

<asp:ListBox id="ListBox1" name="ListBox1" DataSource='<%#
GetDropDownQuantities( (BasketLine)DataBinder.Eval(Container,"DataItem"))
%>'
Rows="1"
CssClass="orderselect"
SelectionMode=Single
runat="server">
</asp:ListBox>


public ListItemCollection GetDropDownQuantities( BasketLine bl)
{
ListItemCollection listBoxData = new ListItemCollection();

int x=0;
bool isSelected = false;
while (x++ < 20)
{
ListItem li = new ListItem();
li.Value = x.ToString();
li.Text = x.ToString();
if (x==bl.Quantity && !isSelected)
{
li.Selected = true;
isSelected = true;
}
listBoxData.Add(li);

}
return listBoxData;
}

thanks

John


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RadioButtonList and SelectedIndex Lav KG ASP .Net 2 08-24-2006 04:10 AM
DataView, DataGrid sorting and incorrect SelectedIndex brian_is_online@yahoo.co.uk ASP .Net 0 07-18-2006 04:55 PM
'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive (part 2) Stimp ASP .Net 5 11-08-2005 04:16 PM
'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive Stimp ASP .Net 2 10-24-2005 01:53 PM
datalist and selectedindex please helpppppppppppppppppppp =?Utf-8?B?bWFoc2E=?= ASP .Net 1 04-30-2004 10:15 AM



Advertisments