Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Linq-to-sql Asp.Net

Linq-to-sql Asp.Net

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehtmlasp-netlinq
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Morgs Morgan
    wrote on last edited by
    #1

    Hi guys, Am using linq-to sql to read from the database which returns a LIST<>, but i wana create a html Table on runtime and fill this table with data that is in the LIST<> i have tried this:

    List<campaign> search = new List<campaign>();
    search = dbh.GetSearchCampaign();

    //create a new table and insert search results..
    Table csr = new Table();
    csr.ID = "ctb";
    TableRow tr;// = new TableRow();
    //tr.ID = "ctr";
    //tr.Style.Value = "cursor:pointer;";

    TableCell td = new TableCell();
    //td.ID = "ctd";
    //format the table
    csr.CellPadding = 0;
    csr.CellSpacing = 0;
    //csr.Width = 578;
    csr.Style.Value = "width: 578px; font-family: 'Adobe Caslon Pro'; font-size: 15px; padding-left: 10px; text-align: left;";
    tr = new TableRow();
    td = new TableCell();
    for (int i = 0; i < search.Count; i++)
    {
    td.Text = search[i];
    }

    But this only adds one row which is the last row in the LIST<>...it's not appending all the rows that are in the LIST<> Does anyone know how i can write all the elements in this LIST<> to an html Table? Please help me. :doh:

    A R 2 Replies Last reply
    0
    • M Morgs Morgan

      Hi guys, Am using linq-to sql to read from the database which returns a LIST<>, but i wana create a html Table on runtime and fill this table with data that is in the LIST<> i have tried this:

      List<campaign> search = new List<campaign>();
      search = dbh.GetSearchCampaign();

      //create a new table and insert search results..
      Table csr = new Table();
      csr.ID = "ctb";
      TableRow tr;// = new TableRow();
      //tr.ID = "ctr";
      //tr.Style.Value = "cursor:pointer;";

      TableCell td = new TableCell();
      //td.ID = "ctd";
      //format the table
      csr.CellPadding = 0;
      csr.CellSpacing = 0;
      //csr.Width = 578;
      csr.Style.Value = "width: 578px; font-family: 'Adobe Caslon Pro'; font-size: 15px; padding-left: 10px; text-align: left;";
      tr = new TableRow();
      td = new TableCell();
      for (int i = 0; i < search.Count; i++)
      {
      td.Text = search[i];
      }

      But this only adds one row which is the last row in the LIST<>...it's not appending all the rows that are in the LIST<> Does anyone know how i can write all the elements in this LIST<> to an html Table? Please help me. :doh:

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      You have to add each cell to the row then add the row to the table: you'll need to adjust your loop and find the code fragments that will accomplish this for you (along the lines of row.cells.add(cell)).

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      1 Reply Last reply
      0
      • M Morgs Morgan

        Hi guys, Am using linq-to sql to read from the database which returns a LIST<>, but i wana create a html Table on runtime and fill this table with data that is in the LIST<> i have tried this:

        List<campaign> search = new List<campaign>();
        search = dbh.GetSearchCampaign();

        //create a new table and insert search results..
        Table csr = new Table();
        csr.ID = "ctb";
        TableRow tr;// = new TableRow();
        //tr.ID = "ctr";
        //tr.Style.Value = "cursor:pointer;";

        TableCell td = new TableCell();
        //td.ID = "ctd";
        //format the table
        csr.CellPadding = 0;
        csr.CellSpacing = 0;
        //csr.Width = 578;
        csr.Style.Value = "width: 578px; font-family: 'Adobe Caslon Pro'; font-size: 15px; padding-left: 10px; text-align: left;";
        tr = new TableRow();
        td = new TableCell();
        for (int i = 0; i < search.Count; i++)
        {
        td.Text = search[i];
        }

        But this only adds one row which is the last row in the LIST<>...it's not appending all the rows that are in the LIST<> Does anyone know how i can write all the elements in this LIST<> to an html Table? Please help me. :doh:

        A Offline
        A Offline
        Arun Jacob
        wrote on last edited by
        #3

        Your code logic is wrong. You assign text to the same table cell inside for loop. Anyway why don't you use some built-in asp.net data bound controls for doing this?

        Arun Jacob My Technical Blog : Code.NET

        B 1 Reply Last reply
        0
        • A Arun Jacob

          Your code logic is wrong. You assign text to the same table cell inside for loop. Anyway why don't you use some built-in asp.net data bound controls for doing this?

          Arun Jacob My Technical Blog : Code.NET

          B Offline
          B Offline
          brunoseixas
          wrote on last edited by
          #4

          o grande problema é q vc tem q deixar de ser burro, mundiça

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups