HtmlTable ptable = new HtmlTable(); //创建一个表htmltable表
ptable.SkinID = "";
ptable.Style.Add("border", "1");
ptable.Style.Add("width", "100%");
ptable.Style.Add("CellPadding", "1");
ptable.Style.Add("CellSpacing", "1");
ptable.Style.Add("align", "center");
//从数据库取数据,是要赋值与htmltable控件的.
int i = 0;
for (int rowcount = 0; rowcount < 5; rowcount++)
{
HtmlTableRow row = new HtmlTableRow();
for (int cellcount = 0; cellcount < 4; cellcount++)
{
HtmlTableCell cell;
if (rowcount <= 0)
{
cell = new HtmlTableCell("td");
}
else
{
cell = new HtmlTableCell();
}
if (i < ds.Tables[0].Rows.Count)
{
LinkButton lbtn = new LinkButton();
lbtn.ID = "lbtn" + i.ToString();
int num = i++;
lbtn.Text = ds.Tables[0].Rows[num]["Mname"]==null?"":ds.Tables[0].Rows[num]["Mname"].ToString();//要显示的内容
// lbtn.PostBackUrl = "Member.aspx?id=" + ds.Tables[0].Rows[num]["pageID"] == null ? "" : ds.Tables[0].Rows[num]["pageID"].ToString();
// lbtn.ForeColor = System.Drawing.Color.SeaGreen;
// lbtn.Font.Size = FontUnit.Larger;
cell.Style.Add("border-top-width", "1px");
cell.Style.Add("border-right-width", "1px");
cell.Style.Add("border-bottom-width", "1px");
cell.Style.Add("border-left-width", "1px");
cell.Style.Add("border-top-style", "solid");
cell.Style.Add("border-right-style", "solid");
cell.Style.Add("border-bottom-style", "solid");
cell.Style.Add("border-left-style", "solid");
cell.Style.Add("border-top-color", "#CCCCCC");
cell.Style.Add("border-right-color", "#CCCCCC");
cell.Style.Add("border-bottom-color", "#CCCCCC");
cell.Style.Add("border-left-color", "#CCCCCC");
cell.Style.Add("border-left-color", "#CCCCCC");
cell.Controls.Add(lbtn);
}
row.Cells.Add(cell);
}
ptable.Rows.Add(row);
}
tdintrp.Controls.Add(ptable);//tdintrp为网页中的td元素(runat=“server”)
ptable.SkinID = "";
ptable.Style.Add("border", "1");
ptable.Style.Add("width", "100%");
ptable.Style.Add("CellPadding", "1");
ptable.Style.Add("CellSpacing", "1");
ptable.Style.Add("align", "center");
//从数据库取数据,是要赋值与htmltable控件的.
int i = 0;
for (int rowcount = 0; rowcount < 5; rowcount++)
{
HtmlTableRow row = new HtmlTableRow();
for (int cellcount = 0; cellcount < 4; cellcount++)
{
HtmlTableCell cell;
if (rowcount <= 0)
{
cell = new HtmlTableCell("td");
}
else
{
cell = new HtmlTableCell();
}
if (i < ds.Tables[0].Rows.Count)
{
LinkButton lbtn = new LinkButton();
lbtn.ID = "lbtn" + i.ToString();
int num = i++;
lbtn.Text = ds.Tables[0].Rows[num]["Mname"]==null?"":ds.Tables[0].Rows[num]["Mname"].ToString();//要显示的内容
// lbtn.PostBackUrl = "Member.aspx?id=" + ds.Tables[0].Rows[num]["pageID"] == null ? "" : ds.Tables[0].Rows[num]["pageID"].ToString();
// lbtn.ForeColor = System.Drawing.Color.SeaGreen;
// lbtn.Font.Size = FontUnit.Larger;
cell.Style.Add("border-top-width", "1px");
cell.Style.Add("border-right-width", "1px");
cell.Style.Add("border-bottom-width", "1px");
cell.Style.Add("border-left-width", "1px");
cell.Style.Add("border-top-style", "solid");
cell.Style.Add("border-right-style", "solid");
cell.Style.Add("border-bottom-style", "solid");
cell.Style.Add("border-left-style", "solid");
cell.Style.Add("border-top-color", "#CCCCCC");
cell.Style.Add("border-right-color", "#CCCCCC");
cell.Style.Add("border-bottom-color", "#CCCCCC");
cell.Style.Add("border-left-color", "#CCCCCC");
cell.Style.Add("border-left-color", "#CCCCCC");
cell.Controls.Add(lbtn);
}
row.Cells.Add(cell);
}
ptable.Rows.Add(row);
}
tdintrp.Controls.Add(ptable);//tdintrp为网页中的td元素(runat=“server”)