Avatar of thorv71
thorv71
Flag for Norway

asked on 

Table sorting ADO.NET dynamic

I have a following table with my own style sheet, I want to sort on it, without using gridwiew.

you can look at my code below and picture of the menu.

aspx.cs

 protected void Page_Load(object sender, EventArgs e)
    {
        string Knyttning = "SQL CONNECTIO HERE";

        SqlConnection dbKnyttning = new SqlConnection(Knyttning);
        string sqlKommando = "Select * from ordrer";
        SqlCommand resultat = new SqlCommand(sqlKommando, dbKnyttning);

        try
        {
            dbKnyttning.Open();
            SqlDataReader rad = resultat.ExecuteReader(CommandBehavior.CloseConnection);
            double totallsumordre = 0;
            double totallsumlevert = 0;

            while (rad.Read())
            {
     
             
                lblOrdrenr.Text += " "  + rad["ordrenummer"] +"<br/>";
                lblOrdredato.Text += " " + string.Format("{0:dd/MM/yyyy}", rad["ordredato"]) + "<br/>";
                lblLevdato.Text += " " + string.Format("{0:dd/MM/yyyy}", rad["leveringsdato"]) + "<br/>";
                int sta = (int)rad["status"];
                int typ = (int)rad["Type"];
                if (sta == 1000)
                {
                    lblStatus.Text += "Standard" + "<br/>";
                }
                else if (sta == 1002)
                {
                    lblStatus.Text += "" + "Bekreftet" + "<br/>";
                }
                else if (sta == 1005)
                {
                    lblStatus.Text += "Venteordre" + "<br/>";
                }
                else if (sta == 1010)
                {
                    lblStatus.Text += "Bekreftet" + "<br/>";
                }
                else
                    lblStatus.Text += rad["Status"] + "<br/>";


                lblKontaktP.Text += " " + rad["kontaktperson"] + "<br/>";
                lblSumOrdre.Text += " " + rad["sumordre"] + "<br/>";
                lblSumLevert.Text += " " + rad["sumlevert"] + "<br/>";
                if (typ == 100)
                {
                    lblType.Text += " " + "Salgsordre" + "<br/>";
                }
                else if (typ == 140)
                {
                    lblType.Text += " " + "Prosjektordre" + "<br/>";
                }
                else if (typ == 150)
                {
                    lblType.Text += " " + "Tilbud" + "<br/>";
                }
                else
                {
                    lblType.Text += " " + rad["Type"] + "<br/>";
                }
                double sumordre = Convert.ToDouble(rad["sumordre"]);
                double sumlevert = Convert.ToDouble(rad["sumlevert"]);

                totallsumordre += sumordre;
                totallsumlevert += sumlevert;
            }

            lbltotalsumordre.Text += " " + totallsumordre;
            lbltotalsumlevert.Text += " " + totallsumlevert;
        }
        catch (Exception feil)
        {
            Response.Write("Feil i SQL: " + feil.Message.ToString());
        }
        finally
        {
            if (dbKnyttning.State != ConnectionState.Closed)
            {
                dbKnyttning.Close();
            }
        }


    }



aspx file

   <table style="width: auto; height: 133px;">
            <tr>
            <td class="MainTextTitle" style="border-bottom-style:solid; border-bottom-width:thin; border-bottom-color:#A3B1D8;"> Ordren</td>
                 
               
                   
                <td class="style99">
                </td>
             
                <td  class="MainTextTitle" style="border-bottom-style:solid; border-bottom-width:thin; border-bottom-color:#A3B1D8">
                    Ordredato</td>

               
                <td  class="style184">
                    &nbsp;</td>

               
                                <td class="MainTextTitle" style="border-bottom-style:solid; border-bottom-width:thin; border-bottom-color:#A3B1D8">
                    Levdato</td>

               
                                <td class="style184">
                                    &nbsp;</td>
                <td class="MainTextTitle" style="border-bottom-style:solid; border-bottom-width:thin; border-bottom-color:#A3B1D8">
                    Status</td>
                <td class="style184">
                    &nbsp;</td>
                <td class="MainTextTitle" style="border-bottom-style:solid; border-bottom-width:thin; border-bottom-color:#A3B1D8">
                    Type&nbsp; </td>
                <td class="style184">
                    &nbsp;</td>
                <td class="style188"
                    style="border-bottom-style:solid; border-bottom-width:thin; border-bottom-color:#A3B1D8">
                    Kontaktperson</td>
                <td class="style184"
                    &nbsp;</td>
                <td style="text-align:right; border-bottom-style:solid; border-bottom-width:thin; border-bottom-color:#A3B1D8;" class="MainTextTitle" >
                    Sum ordre</td>
                <td class="style189">
                    </td>
                <td style="text-align:right; border-bottom-style:solid; border-bottom-width:thin; border-bottom-color:#A3B1D8"
                    class="style193">
                    Sum levert</td>
                <td class="style152">
                    &nbsp;</td>
            </tr>
            <tr>
               
                <td class="OrdrenrMellom">
                    <asp:Label ID="lblOrdrenr" runat="server" style="font-size: small"></asp:Label>
                   </td>
                <td class="style196">
                    &nbsp;</td>
                <td class="OrdredatoMellomrom">
                    <asp:Label ID="lblOrdredato" runat="server" CssClass="style54"></asp:Label>
                </td>
                <td class="style86">
                    &nbsp;</td>
                <td class="style100">
                    <asp:Label ID="lblLevdato" runat="server" CssClass="style54"></asp:Label>
                </td>
                <td class="style128">
                    &nbsp;</td>
                <td class="style100">
                    <asp:Label ID="lblStatus" runat="server" CssClass="style54"></asp:Label>
                </td>
                <td class="style119">
                    &nbsp;</td>
                <td class="style100">
                    <asp:Label ID="lblType" runat="server" CssClass="style54"></asp:Label>
                </td>
                <td class="style173">
                    &nbsp;</td>
               <div>
                <td class="style100">
                    <asp:Label ID="lblKontaktP" runat="server" CssClass="style54"></asp:Label>
                </td>
               <td style="text-align:right" class="style161">
                    &nbsp;</td>
               </div>
               <td style="text-align:right" class="style190">
                    <asp:Label ID="lblSumOrdre" runat="server" position="right" CssClass="style54"></asp:Label>
                    </td>
                <td style="text-align:right" class="style194">
                    &nbsp;</td>
                <td style="text-align:right" class="style192">
                    <asp:Label ID="lblSumLevert" runat="server" CssClass="style54"></asp:Label>
                    </td>
            </tr>
    </p>

    <table style="height: 23px; width: 987px;">
    <tr class="MainText_bunn" onmousedown="this.style.backgroundColor='#8C9CA8';style.color='white" onmouseup="this.style.backgroundColor='#8C9CA8';style.color='white'" >
    <td class="style195" style="background-color: #8C9CA8">
       
       
       
    </td>
    </tr>
    </table>
    <asp:Label ID="lbltotalsumordre" runat="server"
            style="top: 164px; left: 866px; position: absolute; height: 18px; width: 39px; font-size: small; font-family: Tahoma; font-weight: 700; right: 1303px;"
            ></asp:Label>
     
        <asp:Label ID="lbltotalsumlevert" runat="server"
       
            style="font-size: small; font-family: Tahoma; font-weight: 700; top: 164px; left: 934px; position: absolute; height: 21px; width: 162px;"></asp:Label>
     
        <p>
       
            &nbsp;</p>
       
        <asp:Panel ID="vismer" runat="server">
    </asp:Panel>
       
        <p>
       
            <asp:Label ID="Label1" runat="server" Text="Totalt: " 
               
               
                style="font-size: small; font-weight: 700; top: 164px; left: 708px; position: absolute; height: 21px; width: 63px; font-family: Tahoma; color: #FFFFFF;"></asp:Label>
    </p>
    <p>
       
        &nbsp;</p>
                       

hope someone can help, this is very important to me. Tbale
Web Development SoftwareWeb Graphics SoftwareWeb Services

Avatar of undefined
Last Comment
thorv71

8/22/2022 - Mon