listbox control

Results 1 to 2 of 2

Thread: listbox control

  1. #1
    Join Date
    Dec 1969
    DFW, TX

    Default listbox control

    One of the controls on my form is a listbox control. For some reason I cannot get the values passed when the form is posted. Here is the code for the button click event and also the listbox and associated textbox that I use to hold the values in.<BR><BR>[code language="VB.NET"]<BR><BR>&#039;customer has finished and clicked AddLoad Button<BR>Sub AddLoad_Click(sender As Object, e As EventArgs)<BR> If lblBillTo.Text = "" Then &#039;assign a value to prevent an error<BR> If payor.SelectedItem.Value = "ppd" Then &#039;prepaid shipment<BR> lblBillTo.Text = lblShipperID.Text<BR> ElseIf payor.SelectedItem.Value = "clt" Then &#039;collect shipment<BR> lblBillTo.Text = lblConsigneeID.Text<BR> ElseIf payor.SelectedItem.Value = "COD" Then &#039;cod shipment<BR> lblBillTo.Text = lblConsigneeID.Text<BR> End If<BR> End If<BR> &#039;change the datetime textbox to show now so we can use that as an argument<BR> &#039;in a query later on<BR> lblDateTime.Text = Now()<BR> &#039;get the trlr types used put them in hidden textbox for use later<BR> If trlr.SelectedIndex &#062; - 1<BR> &#039;clear the trlr type textbox<BR> theType.Text=""<BR> Dim x as Integer<BR> For x = 0 To trlr.Items.Count - 1<BR> If trlr.Items(x).Selected Then<BR> theType.Text = theType.Text & trlr.Items(x).Value<BR> End If<BR> Next<BR> End If<BR> If multiPick.SelectedItem.Value = "True" Then<BR> multiplePicks = True<BR> End If<BR> If multiStop.SelectedItem.Value = "True" Then<BR> multipleDrops = True<BR> End If<BR> If AddTheLoad(lblCustomerID.Text,lblUserID.Text,lblSh ipperID.Text,lblDateTime.Text,shipDate.Text,multiP ick.SelectedItem.Value,lblConsigneeID.Text, multiStop.SelectedItem.Value,payor.SelectedItem.Va lue,lblBillTo.Text,commodity.Text,weight.Text,rate .Text,ratePer.Text,theType.Text,odWidth.Checked,od Length.Checked,odWeight.Checked,odHeight.Checked,t arps.Checked,ramps.Checked,sides.Checked,ldComment .Text,scheduledDelyDate.Text) &#062; 0 Then<BR> &#039;load has been added succesfully<BR> &#039;look to see if there are multiple stops<BR> If multiplePicks = True OR multipleDrops = True Then<BR> GetLoadID(lblCustomerID.Text,lblShipperID.Text,lbl ConsigneeID.Text,lblDateTime.Text)<BR> If multiplePicks = True Then<BR> &#039;there are multiple picks<BR> Dim i as integer = 1<BR> lblPickNum.Text = i<BR> lblOrigin.Text = "Pick #" & i & " Enroute"<BR> lblShipperId.Text = ""<BR> pnlShipSelect.Visible = True<BR> pnlInfo.Visible = False<BR> pnlMPicks.Visible = False<BR> pnlMStops.Visible = False<BR> pnlBillInfo.Visible = False<BR> btnNew1.Visible = False<BR> btnAddNewPick.Visible = True<BR> previous2.Enabled = False &#039;$$$$$$<BR> Else<BR> &#039;there are multiple drops<BR> Dim i as integer = 1<BR> lblDestination.Text = "Drop #" & i & " Enroute"<BR> lblConsigneeID.Text = ""<BR> pnlRcvSelect.Visible = True<BR> pnlMPicks.Visible = False<BR> pnlMStops.Visible = False<BR> pnlInfo.Visible = False<BR> pnlBillInfo.Visible = False<BR> btnNew3.Visible = False<BR> btnAddNewDrop.Visible = True<BR> previous2.Enabled = False<BR> lblDropNum.Text = i<BR> End If<BR> Else<BR> pnlMPicks.Visible = False<BR> pnlMStops.Visible = False<BR> pnlInfo.Visible = False<BR> pnlBillInfo.Visible = False<BR> btnMorePicks.Visible = False<BR> btnMoreDrops.Visible = False<BR> lblSuccess.Text = "Your load has been added"<BR> pnlSuccess.Visible = True<BR> End If<BR> End If<BR>End Sub<BR><BR>[/code]<BR><BR>here is the html for the listbox and also the associated textbox<BR><BR><BR>&#060;asp:Label id="Label34" runat="server"&#062;Equipment Type&#060;/asp:Label&#062;<BR> &#060;asp:TextBox id="theType" runat="server" visible="False"&#062;&#060;/asp:TextBox&#062;<BR> &#060;br /&#062;<BR> &#060;asp:ListBox id="trlr" runat="server" SelectionMode="Multiple"&#062;&#060;/asp:ListBox&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default make sure

    that if you have some function or sub that "fills" the combobox, make sure you only do it when the page is not postback<BR><BR>in Page_Load event:<BR><BR>If Not Page.IsPostback then<BR> &#039;Fill lists<BR>End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts