473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Asp:ListBox and selectedindex

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
Nov 18 '05 #1
0 1164

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Richard Fennell | last post by:
I am trying to use asp:listbox on a form, when a user selects a row in the asp:listbox a panel is displayed on the centre of the screen with a message, a bit like a model dialog on the form. The...
1
by: Ray Valenti | last post by:
I have a ASP listbox that I am trying to populate with two fields, one for display (Category) and one to store (ID) as the selected item. I can successfully populate and view the list. How ever...
1
by: Daniel | last post by:
hi, I had an asp:listbox, and everytime i click item inside, the bar automatically go to the top, is there any way to keep the scroll position? I turn on the smartNavigation, it still doesn't...
2
by: Dan Nash | last post by:
Hi again! Right, okay... im now trying to get the value of an <asp:TextBox> control. so I have on my ASPX page... <asp:ListBox id="results" runat="server"></asp:ListBox> <asp:TextBox...
2
by: Simon Prince | last post by:
Help I have a ASP:Listbox on a form. My page Adds items to this this via Client-Side Script only. Such as... var vObj_TargetElement =...
3
by: Ryan Taylor | last post by:
Hello. I have an application where I need the user to be able to add items to a listbox. I've implemented this via javascript. The listbox is an <asp:ListBox>. However, when the user submits the...
1
by: dhnriverside | last post by:
Hi guys I've got a List of items for editing a Contact. Basically, it's a list of groups - a contact can be a member of as many as possible, or a member of one. Is there a way to make...
2
by: Mark Rae | last post by:
Hi, Looking for some advice again... Imagine two ListBox controls denoting something like students and team membership e.g. many students can be members of many teams (e.g. the hockey team,...
7
by: mikeh3275 | last post by:
I'm creating a .net program that uploads images to the FTP server. A blank listbox is populated dynamically on the client side from the value of the html input file widget. There is also a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.