联系我们

为客户提供超预期的高品质网站设计!

repeater控件中button按钮事件的使用

2018-2-20 0:00:00

<div>
 <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
      <ItemTemplate>
          <ul>
              <li>
                     <%#Eval("id") %></li>
                <li>
                 <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                <asp:Button ID="Button3" OnClientClick="return confirm('Are u sure?'); runat="server" CommandName="Insert" CommandArgument='<%#Eval("id") %>' Text="添加" /></li>

              </ul>
            </ItemTemplate>
       </asp:Repeater>
   </div>



protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Insert")
        {
            int id = int.Parse(e.CommandArgument.ToString());
            string str = ((TextBox)e.Item.FindControl("TextBox3")).Text;

            //插入数据库
        }
    }        

上一条新闻:asp.net 对话框
下一条新闻:ASP.NET 泛型类型 Dictionary操作

 

400-6137-308 54057491 info@maolian.net