日期:2014-05-17  浏览次数:20415 次

repeater触发事件
 protected void RP_del(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "CN_del")
        {
            using (SqlConnection conn = new SqlConnection("sever=localhost;uid=sa;pwd=9004;database=text2"))
            {
                string sql = "delete from tTable where Name=@name";
                SqlCommand cmd = new SqlCommand(sql,conn);
                cmd.Parameters.AddWithValue("name",e.CommandArgument.ToString());
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                Repeater1.DataSource = ds;
                //int pages = (Convert.ToInt32(totalpage("")) + pagesize - 1) / pagesize;
                Response.Redirect("Default.aspx?page="+Request.QueryString["page"]+"&Sex="+D_sex.SelectedValue+"&Sort="+D_sort.SelectedValue);
            }
        }
        if (e.CommandName == "CN_update")
        {
            L_info.Text = "请输入要更新信息!";
            Btn_insert.Visible = false;
            TB_name.Text = e.CommandArgument.ToString();
            TB_name.ReadOnly = true;
            Btn_update.Visible = true;
        }
    }
点击不触发。
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="RP_del" EnableViewState="true">
                    <ItemTemplate>
<td>
                                <asp:LinkButton ID="LBtn_delete" runat="server" CommandArgument='<%#Eval("Name")%>'
                                    CommandName="CN_del">删除</asp:LinkButton>
 &nb