Multiple select assign.aspx.cs
----------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Kelly.StaffTracker.Utility;
using System.Web.UI.HtmlControls;
using System.Text;
public partial class MultipleTeamSelection : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
Team objLoadTeams = new Team();
List<Team> lstAllTeams = objLoadTeams.GetAllTeams();
if (lstAllTeams != null && lstAllTeams.Count > 0) {
gvTeamList.DataSource = lstAllTeams;
gvTeamList.DataBind();
}
}
protected void btnAssign_Click(object sender, EventArgs e) {
// StringBuilder object
StringBuilder str = new StringBuilder();
// Select the checkboxes from the GridView control
for (int i = 0; i < gvTeamList.Rows.Count; i++) {
GridViewRow row = gvTeamList.Rows[i];
CheckBox obj = (CheckBox)(row.FindControl("chkSelect"));
bool isChecked = obj.Checked;
if (isChecked) {
// Column 2 is the name column
str.Append(gvTeamList.Rows[i].Cells[2].Text);
}
}
// prints out the result
Response.Write(str.ToString());
}
}
|