Click here to Skip to main content
15,925,661 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionOrdering an asp.net Listbox Pin
Senseicads18-Jun-07 0:44
Senseicads18-Jun-07 0:44 
hi
Looking for a bit of help. I have an asp.net listbox. I am wanting to manually be able to order the box by clicking a button. got everything set up but I keep getting an error saying that I can't have multiple selections on the list box when it is set as a single selection. I don't really know where I am going wrong so if anyone can help me I would most appreciate it. My code for the button click is as follows.

Protected Sub btOrderElementUp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btOrderElementUp.Click<br />
        If ltbOrderByList.Items.Count() = 0 Or ltbOrderByList.Items.Count() = 1 Then<br />
            Exit Sub<br />
        End If<br />
<br />
        Dim liItem As ListItem<br />
        Dim intItemIndex As Integer<br />
<br />
        liItem = ltbOrderByList.SelectedItem<br />
        intItemIndex = ltbOrderByList.SelectedIndex<br />
        ltbOrderByList.Items.Insert(intItemIndex - 1, liItem)<br />
        ltbOrderByList.Items.RemoveAt(intItemIndex)<br />
        ltbOrderByList.ClearSelection()<br />
        ltbOrderByList.SelectedIndex = intItemIndex - 1<br />
        <br />
    End Sub


The last two lines are my attempt to manually set the selected item so multiple items definitly aren't selected. If there is an easier way of doing this I would also appreciate it if you could tell me too! Big Grin | :-D

Cheers

Ian
AnswerRe: Ordering an asp.net Listbox Pin
Sylvester george18-Jun-07 1:02
Sylvester george18-Jun-07 1:02 
GeneralRe: Ordering an asp.net Listbox Pin
Senseicads18-Jun-07 1:12
Senseicads18-Jun-07 1:12 
QuestionHow to Declare a variable which is static and also global in vb Pin
Hemant Garg18-Jun-07 0:42
Hemant Garg18-Jun-07 0:42 
AnswerRe: How to Declare a variable which is static and also global Pin
RepliCrux18-Jun-07 0:50
RepliCrux18-Jun-07 0:50 
GeneralRe: How to Declare a variable which is static and also global Pin
Hemant Garg18-Jun-07 1:00
Hemant Garg18-Jun-07 1:00 
AnswerRe: How to Declare a variable which is static and also global in vb Pin
RepliCrux18-Jun-07 0:59
RepliCrux18-Jun-07 0:59 
GeneralRe: How to Declare a variable which is static and also global in vb Pin
Hemant Garg18-Jun-07 1:02
Hemant Garg18-Jun-07 1:02 
QuestionRendered HTML output Pin
moon_stick18-Jun-07 0:35
moon_stick18-Jun-07 0:35 
AnswerRe: Rendered HTML output Pin
N a v a n e e t h18-Jun-07 0:46
N a v a n e e t h18-Jun-07 0:46 
AnswerRe: Rendered HTML output Pin
RichardGrimmer18-Jun-07 0:53
RichardGrimmer18-Jun-07 0:53 
GeneralRe: Rendered HTML output Pin
DavidNohejl18-Jun-07 1:19
DavidNohejl18-Jun-07 1:19 
AnswerRe: Rendered HTML output Pin
moon_stick18-Jun-07 3:20
moon_stick18-Jun-07 3:20 
QuestionSession Problems Pin
Russell Jones18-Jun-07 0:14
Russell Jones18-Jun-07 0:14 
QuestionCoudl not get ListBox Value Pin
J Liang18-Jun-07 0:02
J Liang18-Jun-07 0:02 
AnswerRe: Coudl not get ListBox Value [modified] Pin
RepliCrux18-Jun-07 1:25
RepliCrux18-Jun-07 1:25 
GeneralRe: Coudl not get ListBox Value Pin
J Liang18-Jun-07 15:05
J Liang18-Jun-07 15:05 
AnswerRe: Coudl not get ListBox Value Pin
RepliCrux18-Jun-07 15:16
RepliCrux18-Jun-07 15:16 
GeneralRe: Coudl not get ListBox Value Pin
J Liang18-Jun-07 17:29
J Liang18-Jun-07 17:29 
GeneralRe: Coudl not get ListBox Value Pin
RepliCrux18-Jun-07 17:36
RepliCrux18-Jun-07 17:36 
GeneralRe: Coudl not get ListBox Value Pin
RepliCrux18-Jun-07 17:39
RepliCrux18-Jun-07 17:39 
GeneralRe: Coudl not get ListBox Value Pin
J Liang20-Jun-07 16:03
J Liang20-Jun-07 16:03 
Questiondialog box Pin
niki_nilu17-Jun-07 23:51
niki_nilu17-Jun-07 23:51 
AnswerRe: dialog box Pin
N a v a n e e t h17-Jun-07 23:56
N a v a n e e t h17-Jun-07 23:56 
GeneralRe: dialog box Pin
niki_nilu18-Jun-07 0:03
niki_nilu18-Jun-07 0:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.