前台代码:<div>
<table ID="Tb_adv_search" runat="server">
<tr>
<td><asp:DropDownList ID="Ddl_adv_search1" width="40" runat="server"></asp:DropDownList></td>
<td><asp:DropDownList ID="Ddl_operator1" width="40" runat="server"></asp:DropDownList></td>
<td colspan="2"><asp:TextBox ID="TxtB1" width="100" runat="server"></asp:TextBox></td>
</tr>
</table>
<asp:Button ID="Btn_add_search" runat="server" Text="添加查询条件" OnClick="Btn_add_search_Click"/>
</div>
后台代码:public void Btn_add_search_Click(object sender, EventArgs e)
{
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell td1 = new HtmlTableCell();
HtmlTableCell td2 = new HtmlTableCell();
HtmlTableCell td3 = new HtmlTableCell();
HtmlTableCell td4 = new HtmlTableCell();
DropDownList ddl1 = new DropDownList();
DropDownList ddl2 = new DropDownList();
TextBox Txb = new TextBox();
Button Btn_del = new Button();
Btn_del.Text = "删除";
td1.Controls.Add(ddl1);
td2.Controls.Add(ddl2);
td3.Controls.Add(Txb);
td4.Controls.Add(Btn_del);
tr.Cells.Add(td1);
tr.Cells.Add(td2);
tr.Cells.Add(td3);
tr.Cells.Add(td4);
Tb_adv_search.Rows.Add(tr);
Btn_del.Click += new EventHandler(Btn_del_Click);
}
void Btn_del_Click(object sender, EventArgs e)
{
this.Parent.Parent.Controls.Clear();
}
目的:点击页面上的“添加查询条件”按钮,table自动添加一行,此行有4列,前三列分别为DropDownList、DropDownList、TextBox,第四列为button,并且添加button_onclick事件,点击此按钮,删除当前行问题描述:我的代码只能添加一行,再点击时不再添加,点击删除按钮可以删除此行,但是在Btn_del_Click事件中设置断点,发现程序并没有进去,我知道这些设计viewstate,控件生命周期什么的,不太懂,方便的话顺便指导一下,谢谢!
<table ID="Tb_adv_search" runat="server">
<tr>
<td><asp:DropDownList ID="Ddl_adv_search1" width="40" runat="server"></asp:DropDownList></td>
<td><asp:DropDownList ID="Ddl_operator1" width="40" runat="server"></asp:DropDownList></td>
<td colspan="2"><asp:TextBox ID="TxtB1" width="100" runat="server"></asp:TextBox></td>
</tr>
</table>
<asp:Button ID="Btn_add_search" runat="server" Text="添加查询条件" OnClick="Btn_add_search_Click"/>
</div>
后台代码:public void Btn_add_search_Click(object sender, EventArgs e)
{
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell td1 = new HtmlTableCell();
HtmlTableCell td2 = new HtmlTableCell();
HtmlTableCell td3 = new HtmlTableCell();
HtmlTableCell td4 = new HtmlTableCell();
DropDownList ddl1 = new DropDownList();
DropDownList ddl2 = new DropDownList();
TextBox Txb = new TextBox();
Button Btn_del = new Button();
Btn_del.Text = "删除";
td1.Controls.Add(ddl1);
td2.Controls.Add(ddl2);
td3.Controls.Add(Txb);
td4.Controls.Add(Btn_del);
tr.Cells.Add(td1);
tr.Cells.Add(td2);
tr.Cells.Add(td3);
tr.Cells.Add(td4);
Tb_adv_search.Rows.Add(tr);
Btn_del.Click += new EventHandler(Btn_del_Click);
}
void Btn_del_Click(object sender, EventArgs e)
{
this.Parent.Parent.Controls.Clear();
}
目的:点击页面上的“添加查询条件”按钮,table自动添加一行,此行有4列,前三列分别为DropDownList、DropDownList、TextBox,第四列为button,并且添加button_onclick事件,点击此按钮,删除当前行问题描述:我的代码只能添加一行,再点击时不再添加,点击删除按钮可以删除此行,但是在Btn_del_Click事件中设置断点,发现程序并没有进去,我知道这些设计viewstate,控件生命周期什么的,不太懂,方便的话顺便指导一下,谢谢!
解决方案 »
- 模块拖动问题
- 关于cache缓存问题
- 关于使用flexpaper实现在线阅读防止下载的问题
- 我在网上下载的对联广告 代码,在IE其他版本测试都正常,但是在IE9里面无法显示,哪位大神帮忙改一下,万分感激!
- 在ASP.NET中实现Winform中的Validated事件
- 经过四年奋斗,李开复始终无法获得北京户口,只有廊坊地区表示了欢迎,造成李开复女儿无法在北京市入学,只能送往美国就读的现实困境。为了孩子的未来,他毅然决定辞职,回
- 请教一个问题哦~~~`````知道的朋友请帮忙
- 麻烦看一下我这文件那里错了!
- 用C#开发WEB程序,能否实现这样的代码执行功能?请大家帮忙!
- 大虾们说说ASP转ASP。NET的理由, 一定用ASP。NET吗? 不是用ASP也一样做到?
- .Net开发
- 查询连接网络的ip地址
如果是以行出现的,那么你可以在点击添加行的时候判断目前有几个button了。
如果超过了4个就不准添加,低于3个就不准移除。