62,046
社区成员
发帖
与我相关
我的任务
分享
<form id="Form1" method="post" runat="server">
<table>
<tr>
<td align="right" class="style3">
<asp:Label ID="Label4" runat="server" Text="IP地址绑定:"></asp:Label>
</td>
<td align="left" class="style3">
<asp:LinkButton ID="lb_AddRows" runat="server" onclick="lb_AddRows_Click">添加一行</asp:LinkButton>
<hr />
<asp:Table id="tableshow" runat="server"></asp:Table>
<hr style="height:1px; background-color:#666666;" />
<asp:PlaceHolder id="phshow" runat="server"></asp:PlaceHolder><br />
</td>
</tr>
</table>
</form>
protected void Page_Load(object sender, EventArgs e)
{
this.lb_KHID.Text = Request.QueryString["KHID"].ToString();
if (ViewState["Count"] != null)
{
for (int i = 0; i < Convert.ToInt32(ViewState["Count"]); i++)
{
AddContent();
}
AddRows();
}
}
private void AddContent()
{
TableRow tr = new TableRow();
TableCell tc0 = new TableCell();
DropDownList dpl = new DropDownList();
dpl.ID = "dpl" + tableshow.Rows.Count;
dpl.CssClass = "DropDownList";
dpl.Items.Add("内网");
dpl.Items.Add("外网");
tc0.Controls.Add(dpl);
TableCell tc1 = new TableCell();
Label lb1 = new Label();
lb1.ID = "lb1" + tableshow.Rows.Count;
lb1.Text = "开始IP:";
lb1.CssClass = "Label";
tc1.Controls.Add(lb1);
TableCell tc2 = new TableCell();
TextBox tb1 = new TextBox();
tb1.CssClass = "TextBox";
tb1.Width = 100;
tb1.ID = "tb1" + tableshow.Rows.Count;
tc2.Controls.Add(tb1);
TableCell tc3 = new TableCell();
Label lb2 = new Label();
lb2.ID = "lb2" + tableshow.Rows.Count;
lb2.Text = "截止IP:";
lb2.CssClass = "Label";
tc3.Controls.Add(lb2);
TableCell tc4 = new TableCell();
TextBox tb2 = new TextBox();
tb2.CssClass = "TextBox";
tb2.Width = 100;
tb2.ID = "tb2" + tableshow.Rows.Count;
tc4.Controls.Add(tb2);
tr.Cells.Add(tc0);
tr.Cells.Add(tc1);
tr.Cells.Add(tc2);
tr.Cells.Add(tc3);
tr.Cells.Add(tc4);
tableshow.Rows.Add(tr);
}
private void AddRows()
{
Button b = new Button();
b.ID = "btn";
b.Text = "提交";
b.CssClass = "Button";
b.Click += new System.EventHandler(btn_Click);
phshow.Controls.Add(b);
}
private void btn_Click(object sender, System.EventArgs e)
{
for (int i = 0; i < tableshow.Rows.Count; i++)
{
int LX = -1;
if (((DropDownList)tableshow.Rows[i].FindControl("dpl" + i)).SelectedValue == "内网")
{
LX = 1;
}
else
{
LX = 0;
}
Hashtable ht = new Hashtable();
ht.Add("KHID", Convert.ToInt32(Request.QueryString["KHID"]));
ht.Add("QSIP", inet_addr(((TextBox)tableshow.Rows[i].FindControl("tb1" + i)).Text.ToString()));
ht.Add("JZIP", inet_addr(((TextBox)tableshow.Rows[i].FindControl("tb2" + i)).Text.ToString()));
ht.Add("LX", Convert.ToInt32(LX));
Mapper.Instance().QueryForObject("Procedure.GetIpBinding", ht);
}
}
protected void lb_AddRows_Click(object sender, EventArgs e)
{
AddContent();
if (ViewState["Count"] == null) AddRows();
ViewState["Count"] = Convert.ToInt32(ViewState["Count"]) + 1;
}