Example #1
0
        protected void DetailsViewForMember_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
        {
            //ugly solution to find Member id, but spent hours trying to find another soulution without luck
            var key        = e.Keys.Values;
            var enumerator = key.GetEnumerator();

            enumerator.MoveNext();

            Member member = new Member();

            member.MemberID     = (int)enumerator.Current;
            member.Name         = (DetailsViewForMember.Rows[1].FindControl("TextBox1") as TextBox).Text;
            member.StreetAddres = (DetailsViewForMember.Rows[1].FindControl("TextBox2") as TextBox).Text;
            member.City         = (DetailsViewForMember.Rows[1].FindControl("TextBox3") as TextBox).Text;
            member.Zip          = (DetailsViewForMember.Rows[1].FindControl("TextBox4") as TextBox).Text;
            member.Email        = (DetailsViewForMember.Rows[1].FindControl("TextBox5") as TextBox).Text;
            member.State        = (State)Enum.Parse(typeof(State), (DetailsViewForMember.Rows[1].FindControl("DdlForState") as DropDownList).SelectedValue, true);
            member.Code         = (DetailsViewForMember.Rows[1].FindControl("TextBox6") as TextBox).Text;
            member.Status       = (MemberStatus)Enum.Parse(typeof(MemberStatus), (DetailsViewForMember.Rows[1].FindControl("DdlForStatus") as DropDownList).SelectedValue, true);
            memberService.upsertMember(member);
            DetailsViewForMember.ChangeMode(DetailsViewMode.ReadOnly);
            Session["Member"]             = null;
            GridViewMembers.SelectedIndex = -1;
            BindMemberData();
            BindDetailViewForMember();
        }
Example #2
0
 protected void DetailsViewForMember_ModeChanging(object sender, DetailsViewModeEventArgs e)
 {
     DetailsViewForMember.ChangeMode(e.NewMode);
     if (e.CancelingEdit)
     {
         DetailsViewForMember.ChangeMode(DetailsViewMode.ReadOnly);
     }
     BindDetailViewForMember();
 }
Example #3
0
        protected void GridViewMembers_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var    row  = GridViewMembers.Rows[e.RowIndex];
            string Code = (row.FindControl("Label6") as Label).Text;

            memberService.deleteMember(Code);
            DetailsViewForMember.ChangeMode(DetailsViewMode.ReadOnly);
            BindMemberData();
            BindDetailViewForMember();
        }
Example #4
0
 protected void GridViewMembers_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Select")
     {
         int MemberId = (int)this.GridViewMembers.DataKeys[Int32.Parse(e.CommandArgument.ToString())].Value;
         var member   = memberService.getAllMembers().Where(x => x.MemberID == MemberId).ToList();
         Session["Member"] = member;
         DetailsViewForMember.ChangeMode(DetailsViewMode.ReadOnly);
         BindDetailViewForMember();
     }
     BindMemberData();
 }
Example #5
0
 private void BindDetailViewForMember()
 {
     if (Session["Member"] != null)
     {
         DetailsViewForMember.DataSource = Session["Member"];
     }
     else
     {
         //force the detail view into insert mode
         DetailsViewForMember.ChangeMode(DetailsViewMode.Insert);
     }
     DetailsViewForMember.DataBind();
 }
Example #6
0
        protected void DetailsViewForMember_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            Member member = new Member();

            member.Name         = (DetailsViewForMember.Rows[1].FindControl("TextBox1") as TextBox).Text;
            member.StreetAddres = (DetailsViewForMember.Rows[1].FindControl("TextBox2") as TextBox).Text;
            member.City         = (DetailsViewForMember.Rows[1].FindControl("TextBox3") as TextBox).Text;
            member.Zip          = (DetailsViewForMember.Rows[1].FindControl("TextBox4") as TextBox).Text;
            member.Email        = (DetailsViewForMember.Rows[1].FindControl("TextBox5") as TextBox).Text;
            member.Status       = (MemberStatus)Enum.Parse(typeof(MemberStatus), (DetailsViewForMember.Rows[1].FindControl("DdlForStatus") as DropDownList).SelectedValue, true);
            member.State        = (State)Enum.Parse(typeof(State), (DetailsViewForMember.Rows[1].FindControl("DdlForState") as DropDownList).SelectedValue, true);
            member.Code         = (DetailsViewForMember.Rows[1].FindControl("TextBox6") as TextBox).Text;
            memberService.upsertMember(member);
            DetailsViewForMember.ChangeMode(DetailsViewMode.ReadOnly);
            GridViewMembers.SelectedIndex = -1;
            BindMemberData();
            BindDetailViewForMember();
        }