Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

ListBox Data

$
0
0
I have an web application with dropdowlist, two textboxes, Listbox and button "AddAll"
<asp:Label 

           ID="lblYear" 
           runat="server" 
           Text="Year:" 
           Font-Bold ="True" 
           Width="37px" 
           CssClass ="left"  
           Font-Names ="verdana" 
           Font-Size ="9pt"
           ForeColor ="#444444" 
           Height="21px" 
           BorderColor="White"
           style="margin-left :2px"  ></asp:Label><asp:DropDownList 
       ID="ddlYear" 
       runat="server" 
       Width="124px" Height="16px" ></asp:DropDownList><br /><br /><asp:Label 
     ID="lblPage" 
     runat="server" 
     Text="Page:" 
     Font-Bold ="True" 
     Width="35px" 
     CssClass ="left" 
      Font-Names ="verdana" 
     Font-Size ="9pt"
     ForeColor ="#444444"
     Height="21px" 
     style="margin-left :3px" ></asp:Label><asp:TextBox 
     ID="TxtPage" 
     runat="server" 
      Width="28px">1</asp:TextBox><br /><br /><asp:Label 
      ID="lblSheet" 
      runat="server" 
      Text="Sheet:" 
      Width="20px" 
      Font-Names ="verdana" 
      Font-Size ="9pt"
      ForeColor ="#444444" 
      Height="21px"
      style="margin-left :2px"  ></asp:Label><asp:TextBox 
     ID="txtSheetNumber" 
     runat="server" 
     Width="26px"
     style="margin-left : 45px">1</asp:TextBox><div style="padding: 25px; "></div><asp:Label 
      ID="Lblsize" 
      runat="server" 
      Width ="28px">Size:</asp:Label><asp:RadioButton 
      ID="OptSmalll" 
      runat="server" 
      GroupName="PlatSize" 
      Text ="Small"/><asp:RadioButton 
      ID="OptLargee" 
      runat="server" 
      Text ="Large" /><asp:Label 
     ID="LblQty" 
     runat="server"  >Qty:</asp:Label><asp:TextBox 
       ID="TxtQty" 
       runat="server" 
       Width="26px">1</asp:TextBox><br /><br /><asp:Button 
     ID="btnAddAll" 
     runat="server" 
     Text="Add All"
      ForeColor="#444444" 
      Width="78px" 
      Height="21px" /><asp:ListBox 
     ID="lstList" 
     runat="server" 
      Height="177px" 
      Width="304px"</asp:ListBox>

the vb code is:

Private Sub btnAddAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddAll.Click


        Dim strSQL As String

        Dim strCnn As String

        Dim cnn As SqlConnection

        Dim da As SqlDataAdapter

        Dim ds As Data.DataSet

        Dim sheet As Integer = 1

        Dim book, page As String

        Dim display, book, page, size, quantity As String


        strCnn = System.Configuration.ConfigurationManager.AppSettings("ConnStr")

        cnn = New SqlConnection(strCnn)

        book = Me.ddlSubYear.Items.Item(Me.ddlSubYear.SelectedIndex).Text

        page = Me.TxtSubNum.Text


Dim index2 As Integer = lstList.Items.Count


While True

            strSQL = _

“SELECT makers_ABC.Book, makers_ABC.Pageno, makers_ABC.size, makers_ABC.page, makers_ABC.quantity

From makers_ABC_DOC

WHERE makers_ABC.index = '" + book + page + "' And makers_ABC.page '" + sheet.ToString + "'  ORDER By makers_Abc.pageno ASC”


             da = New SqlDataAdapter(strSQL, strCnn)

            ds = New Data.DataSet

            da.Fill(ds, "Makers")


  If OptSmalll.Checked Then
                size = "Small"
            Else
                size = "Large"
            End If


      display = book & "-" & page & ", Sheet " & sheet & addSpaces("sub") & size & addSpaces(size) & quantity


         lstList.Items.Insert(index2, New ListItem(display))

            sheet = sheet + 1
         End While
     End Sub

SQL tables don't have any primary keys, just data type integer and when I run the sql query the results are:

 

book | pageno |  page |   sub  |   size  | Qty

2009 | 101      |   1    | desc   | small    |  1
2009 | 101      |   2    | desc   | small    |  1
2009 | 101      |   3    | desc   | small    |  1

When I run the asp.net web application , after searching the Listbox is displaying this results:

2009101, Sheet 3   desc  small     1

2009101,  Sheet 2   desc  small     1

2009101,  Sheet 1   desc  small     1

and why the Listbox is not giving the results I want in ordering way like this:

2009101, Sheet 1   desc  small     1
2009101, Sheet 2   desc  small     1
2009101, Sheet 3   desc  small     1

Your attention and help is very appreicated. Thanks





Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>