Add a button in repeater, and click the button to get the data of a row

Source: Internet
Author: User

1. Add edit button and delete button

<Asp: repeater id = "repeater1" runat = "server" onitemcommand = "repeaterincluitemcommand"> <itemtemplate> <Table width = "100%" border = "1" cellpadding = "0" cellspacing =" 0 "> <tr> <TD style =" width: 15%; "class =" style2 "> <% # eval (" e_name ") %> </TD> <asp: imagebutton id = "imagebutton1" runat = "server" commandname = "justedit" imageurl = "~ /Icon./edit.gif "/> <asp: imagebutton id =" btn_del "runat =" server "commandname =" justdelete "imageurl = "~ /Icon./del.gif "onclientclick =" Return confirm ('Are you sure you want to delete it? ') "/> </TD> </tr> </table> </itemtemplate>

 

2. Select the Repeater control and add the event function onitemcommand.

3. Add function content

Protected void repeaterincluitemcommand (Object source, repeatercommandeventargs e) {datarowview rowview = (datarowview) E. item. dataitem; string STR = rowview. row ["e_id"]. tostring (); // obtain the value of the field c_id if (E. commandname = "justdelete") {bll_emp BLL = new bll_emp (); BLL. delete (STR); server. transfer ("~ /EMP/employee. aspx "); // refresh} else if (E. commandname =" justedit ") {response. Redirect ("~ /EMP/updateemployee. aspx? E_id = "+ Str. tostring () +" & c_id = "+ request. querystring [" c_id "]. tostring ());}}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.