码迷,mamicode.com
首页 > 其他好文 > 详细

Repeater中添加按钮实现点击按钮获取某一行数据的方法

时间:2017-11-13 22:58:59      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:点击   padding   object   inter   lsp   help   全屏   dna   定时   

本文以一个asp.net程序为例讲述了Repeater中添加按钮实现点击按钮获取某一行数据的方法,分享给大家供大家参考借鉴之用。具体步骤如下:


1.添加编辑按钮和删除按钮

具体代码如下:

<asp:Repeater ID="Repeater1" runat="server"
  onitemcommand="Repeater1_ItemCommand">
  <ItemTemplate>
 <table width="100%" border="1" cellpadding="0" cellspacing="0">
   <tr>
               <td style="width: 15%;" class="style2">
   <%#Eval("E_Name")%>
 </td>
 <td>
   <asp:ImageButton ID="ImageButton1" runat="server" CommandName="JustEdit" ImageUrl="~/icon./edit.gif" CommandArgument=<%#Eval("E_ID")%>/>
   <asp:ImageButton ID="btn_del" runat="server" CommandName="JustDelete" ImageUrl="~/icon./del.gif" OnClientClick="return confirm(‘确认删除?‘)"
     CommandArgument=<%#Eval("E_Id")%> />
 </td>
   </tr>
 </table>
  </ItemTemplate>
</Repeater>


2.选中Repeater控件,添加事件函数onitemcommand

如下图所示:

技术分享


3.添加函数内容

具体功能代码如下:

protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    Int32 eid = Convert.ToInt32(e.CommandArgument.ToString());//获取E_ID的值
    if (e.CommandName == "JustDelete")
    {
      BLL_Emp bll = new BLL_Emp();
      bll.Delete(eid);
      Server.Transfer("~/emp/Employee.aspx");//刷新
    }
    else if (e.CommandName == "JustEdit")
    {
      Response.Redirect("~/emp/UpdateEmployee.aspx?E_Id=" + eid.ToString() + "&C;_Id=" + Request.QueryString["C_Id"].ToString());
    }
}

希望本文所述示例对大家的asp.net程序设计有所帮助。

除声明外,跑步客文章均为原创,转载请以链接形式标明本文地址
  Repeater中添加按钮实现点击按钮获取某一行数据的方法

本文地址:  http://www.paobuke.com/develop/c-develop/pbk23604.html






相关内容

Repeater中添加按钮实现点击按钮获取某一行数据的方法

标签:点击   padding   object   inter   lsp   help   全屏   dna   定时   

原文地址:http://www.cnblogs.com/paobuke/p/7828210.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!