Linq-to-sql Asp.Net
-
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:
-
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:
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
-
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:
-
o grande problema é q vc tem q deixar de ser burro, mundiça