HI all I have been using a function to create the table... this functions accepts a list and 2 content place holders to put table and pager ... but something is going wrong.... the pager css doesnot work correctly... some time it overlaps table ... sometimes it comes outside the table.. I am using this function coz i have table on each page of website ... so I made this function once and call it with the list that I need to populate on a particular page.... can somone tell me why pager is not placed properly outside table... below or above table? here is my code:
public static void CreateTable<T>(List<T> list, PlaceHolder PlaceHolder1, PlaceHolder PlaceHolder2) { DataTable tb=new DataTable(); List<string> columns = new List<string>(); Literal t1 = new Literal(); t1.Text = "<table class=\"tablesorter\" cellspacing=\"1\" border=\"1\">"; PlaceHolder1.Controls.Add(t1); Literal t2 = new Literal(); t2.Text = "<thead>"; PlaceHolder1.Controls.Add(t2); PropertyInfo[] properties = list[0].GetType().GetProperties (); foreach (PropertyInfo pi in properties) { Literal t3 = new Literal(); t3.Text = "<th class=\"header\">" + pi.Name; PlaceHolder1.Controls.Add(t3); Literal t4 = new Literal(); t4.Text = "</th>"; PlaceHolder1.Controls.Add(t4); tb.Columns.Add(pi.Name); columns.Add(pi.Name); } Literal t2end = new Literal(); t2end.Text = "</thead>"; PlaceHolder1.Controls.Add(t2end); Literal tbody = new Literal(); tbody.Text = "<tbody>"; PlaceHolder1.Controls.Add(tbody); object[] ret = new object[columns.Count]; // foreach (BugInfo item in bi) foreach (T item in list) { Literal tr = new Literal(); tr.Text = "<tr>"; PlaceHolder1.Controls.Add(tr); object[] cells = getValues(columns, item); for (int l = 0; l < cells.Count(); l++) { //if (cells[l] == string.Empty || cells[l] == null) //{ // cells[l] = "NA"; //} Literal td = new Literal(); td.Text = "<td>" + cells[l]; PlaceHolder1.Controls.Add(td); Literal tdend = new Literal(); tdend.Text = "</td>"; PlaceHolder1.Controls.Add(tdend); } Literal trend = new Literal(); trend.Text = "</tr>"; PlaceHolder1.Controls.Add(trend); } Literal tbodyend = new Literal(); tbodyend.Text = "</tbody>"; PlaceHolder1.Controls.Add(tbodyend); Literal tfoot = new Literal(); tfoot.Text = "<tfoot>"; PlaceHolder1.Controls.Add(tfoot); //PropertyInfo[] properties = bi[0].GetType().GetProperties (); foreach (PropertyInfo pi in properties) { Literal t3 = new Literal(); t3.Text = "<th>" + pi.Name; PlaceHolder1.Controls.Add(t3); Literal t4 = new Literal(); t4.Text = "</th>"; PlaceHolder1.Controls.Add(t4); } Literal tfootend = new Literal(); tfootend.Text = "</tfoot>"; PlaceHolder1.Controls.Add(tfootend); Literal tend = new Literal(); tend.Text = "</table>"; PlaceHolder1.Controls.Add(tend); Literal clear = new Literal(); clear.Text = "<br clear=\"all\">"; PlaceHolder1.Controls.Add(clear); Literal div = new Literal(); div.Text = "<div id=\"pager\" class=\"pager\">"; PlaceHolder2.Controls.Add(div); Literal form = new Literal(); form.Text = "<form>"; PlaceHolder2.Controls.Add(form); Literal img1 = new Literal(); img1.Text = "<img src=\"images/first.png\" class=\"first\"/ >"; PlaceHolder2.Controls.Add(img1); Literal img2 = new Literal(); img2.Text = "<img src=\"images/prev.png\" class=\"prev\"/ >"; PlaceHolder2.Controls.Add(img2); Literal text1 = new Literal(); text1.Text = "<input type=\"text\" class=\"pagedisplay\"/ >"; PlaceHolder2.Controls.Add(text1); Literal img3 = new Literal(); img3.Text = "<img src=\"images/next.png\" class=\"next.png \"/>"; PlaceHolder2.Controls.Add(img3); Literal img4 = new Literal(); img4.Text = "<img src=\"images/last.png\" class=\"last\"/ >"; PlaceHolder2.Controls.Add(img4); Literal pageExtras = new Literal(); pageExtras.Text = "<select class=\"pagesize\"><option selected=\"selected\" value=" + 10 + ">10</option><option value=" + 20 + ">20</option><option value=" + 30 + ">30</option><option value=" + 40 + ">40</option></select>"; PlaceHolder2.Controls.Add(pageExtras); Literal formend = new Literal(); formend.Text = "</form>"; PlaceHolder2.Controls.Add(formend); Literal endiv = new Literal(); endiv.Text = "</div>"; PlaceHolder2.Controls.Add(endiv); } Thnks for any help!! Varun