第一次用到 (object sender)

                                  <asp:CheckBox ID="cbActive" runat="server" AutoPostBack="true" ForeColor="blue"
                                    Checked='<%# DataBinder.Eval(Container.DataItem, "IsApproved") %>' 
                                    ToolTip='<%# DataBinder.Eval(Container.DataItem, "UserName") %>'
                                     OnCheckedChanged="CheckBox_Click"/>





  protected void CheckBox_Click(object sender, EventArgs e)
    {
        try
        {
            CheckBox cbIsApproved = (CheckBox)sender;
            string username = cbIsApproved.ToolTip;
            MembershipUser mu = Membership.GetUser(username);
            mu.IsApproved = cbIsApproved.Checked;
            Membership.UpdateUser(mu);
            gvUsers.DataSource = Membership.GetAllUsers();
            gvUsers.DataBind();
            lbMessage.Text = "更新成功。";

        }
        catch (System.Configuration.Provider.ProviderException ex)
        {
            lbMessage.Text = ex.Message;
        }
    }

posted @ 2008-06-14 11:56  不染丹心  阅读(179)  评论(0编辑  收藏  举报