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 ());}}