public List<AdditionalGroup> GetGridViewGroups() { List<AdditionalGroup> additionalGroups = new List<AdditionalGroup>(); for (int i = 0; i < gvAdditionalGroups.Rows.Count; i++) { GridViewRow row = gvAdditionalGroups.Rows[i]; ImageButton cmdEdit = (ImageButton)row.FindControl("cmdEdit"); if (cmdEdit == null) continue; AdditionalGroup group = new AdditionalGroup(); group.GroupId = (int)gvAdditionalGroups.DataKeys[i][0]; group.GroupName = ((Literal)row.FindControl("litDisplayAdditionalGroup")).Text; additionalGroups.Add(group); } return additionalGroups; }
protected void btnAddAdditionalGroup_Click(object sender, EventArgs e) { if (!Page.IsValid) return; List<AdditionalGroup> additionalGroups = GetGridViewGroups(); AdditionalGroup additionalGroup = new AdditionalGroup(); additionalGroup.GroupId = additionalGroups.Count != 0 ? additionalGroups.Select(x => x.GroupId).Max() + 1 : 1; additionalGroup.GroupName = txtAdditionalGroup.Text; additionalGroups.Add(additionalGroup); BindAdditionalGroups(additionalGroups.ToArray()); txtAdditionalGroup.Text = string.Empty; }
public void SetAdditionalGroups(AdditionalGroup[] additionalGroups) { BindAdditionalGroups(additionalGroups); }
protected void BindAdditionalGroups(AdditionalGroup[] additionalGroups) { gvAdditionalGroups.DataSource = additionalGroups; gvAdditionalGroups.DataBind(); }