关于 PlaceHolder 问题

zlj303 2007-09-10 11:29:14
谁能帮帮我,
已经使用了PlaceHolder1.Controls.Clear();
调用
PlaceHolder1.Controls.Add(table);
确定table中的内容已经改变
而PlaceHolder1显示出来的为什么还是没有变化??
如果我让table多追加几行,前面的几行还是原来的,后面的倒是追加上去了??
...全文
234 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zlj303 2007-09-10
  • 打赏
  • 举报
回复
很急,谁能帮帮我啊??
zhchg6666 2007-09-10
  • 打赏
  • 举报
回复
up
zlj303 2007-09-10
  • 打赏
  • 举报
回复
上面的发错了,这是我写的代码,帮我看看哪里错了:
PlaceHolder1.Controls.Clear();
AuthorDb verty = new AuthorDb();
string finance_id = fin_id.Value.Substring(0, fin_id.Value.Length - 1);
string[] title ={ "finance_id", "house" };
string sql = "select freight,hou_id from finance where finance_id in (" + finance_id + ")";
SqlDataReader ddr = verty.getDataRead(sql);
Table table = new Table();
table.CellPadding = 1;
table.CellSpacing = 1;
table.BorderStyle = 0;
table.BackColor = Color.Black;
TableRow tablerow = new TableRow();

for (int i = 0; i < 2; i++)
{
TableCell tablecell = new TableCell();
tablecell.Attributes.Add("align", "center");
tablecell.Width = Unit.Pixel(65);
tablecell.BackColor = Color.White;
Label label = new Label();
label.Text = title[i];
tablecell.Controls.Add(label);
tablerow.Controls.Add(tablecell);
}
table.Controls.Add(tablerow);

while (ddr.Read())
{

tablerow = new TableRow();
TableCell tablecell = new TableCell();
tablecell.Attributes.Add("align", "center");
tablecell.Width = Unit.Pixel(65);
tablecell.BackColor = Color.White;
TextBox label = new TextBox();
label.Text = ddr["freight"].ToString();
Response.Write(label.Text + "&&");
tablecell.Controls.Add(label);
tablerow.Controls.Add(tablecell);

TableCell tablecel2 = new TableCell();
tablecel2.Attributes.Add("align", "center");
tablecel2.Width = Unit.Pixel(65);
tablecel2.BackColor = Color.White;
TextBox labe2 = new TextBox();
labe2.Text = ddr["hou_id"].ToString();
tablecel2.Controls.Add(labe2);
tablerow.Controls.Add(tablecel2);

table.Controls.Add(tablerow);
}
PlaceHolder1.Controls.Add(table);
zlj303 2007-09-10
  • 打赏
  • 举报
回复
string sql = "select freight,hou_id from finance where finance_id in (" + finance_id + ")";
SqlDataReader ddr = verty.getDataRead(sql);
PlaceHolder1.Controls.Clear();
Table table = new Table();
table.CellPadding = 1;
table.CellSpacing = 1;
table.BorderStyle = 0;
table.BackColor = Color.Black;
TableRow tablerow = new TableRow();

for (int i = 0; i < 3; i++)
{
TableCell tablecell = new TableCell();
tablecell.Attributes.Add("align", "center");
// // tablecell.Width = Unit.Pixel(65);
// // tablecell.BackColor = Color.White;
// // Label label = new Label();
// // label.Text = title[i];
// // tablecell.Controls.Add(label);
// // tablerow.Controls.Add(tablecell);
// //}
// table.Controls.Add(tablerow);

// while (ddr.Read())
// {

// tablerow = new TableRow();
// TableCell tablecell = new TableCell();
// tablecell.Attributes.Add("align", "center");
// tablecell.Width = Unit.Pixel(65);
// tablecell.BackColor = Color.White;
// TextBox label = new TextBox();
// label.Text = ddr["freight"].ToString();
// Response.Write(label.Text + "&&");
// tablecell.Controls.Add(label);
// tablerow.Controls.Add(tablecell);

// //TableCell tablecel2 = new TableCell();
// //tablecel2.Attributes.Add("align", "center");
// //tablecel2.Width = Unit.Pixel(65);
// //tablecel2.BackColor = Color.White;
// //TextBox labe2 = new TextBox();
// //labe2.Text = ddr["hou_id"].ToString();
// //tablecel2.Controls.Add(labe2);
// //tablerow.Controls.Add(tablecel2);

// table.Controls.Add(tablerow);
// // Response.Write(ddr["freight"]);
// }

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧