I want to change a specific text in my gridview here's an image below:
Example if I click the checkbox button the specific row "Status" text is change to "Validated".
This is my aspx code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using MSSQLConnector;
namespace SoftwareAnalysisAndDesign.SAD
{
public partial class TeacherPage : System.Web.UI.Page
{
private MSConnector connector = new MSConnector();
private DataSet SubjectlistData;
private DataTable SubjectlistTable;
string query = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Populate The Select Tag with Subjects
SubjectList.DataSource = Session["TeacherSubjectList"];
SubjectList.DataTextField = "CourseNo";
SubjectList.DataValueField = "CourseNo";
SubjectList.DataBind();
}
}
}
protected void TeacherSubjects_Click(object sender, EventArgs e)
{
string getText = SubjectList.SelectedItem.Text;
//Connection String
connector.ConnectionString = "Data Source=keith;Initial Catalog=SAD;Integrated Security=True";
query = "select StudentID,CourseNo,CourseDescription,Units,Day,StartTime,EndTime,Room,Instructor,Amount,Status from assessmentform where CourseNo = '" + getText + "'";
SubjectlistData = connector.ExecuteQuery(query);
SubjectlistTable = SubjectlistData.Tables[0];
//Add a colum check row
SubjectlistTable.Columns.Add("Check", Type.GetType("System.Boolean"));
Session["ValidateSubject"] = SubjectlistTable;
Response.Redirect("ValidateSubjectTeacher.aspx");
}
I add a checkbox in my row to my gridview using this:
//Add a colum check row
SubjectlistTable.Columns.Add("Check", Type.GetType("System.Boolean"));
Session["ValidateSubject"] = SubjectlistTable;
I pass my gridview using session to another page, its aspx code behind ValidatePage:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SoftwareAnalysisAndDesign.SAD
{
public partial class ValidateSubjectTeacher : System.Web.UI.Page
{
CheckBox check = new CheckBox();
protected void Page_Load(object sender, EventArgs e)
{
if (Session["ValidateSubject"] == null)
{
Response.Redirect("TeacherPage.aspx", true);
}
if (!IsPostBack)
{
ValidateSubject.DataSource = Session["ValidateSubject"];
ValidateSubject.DataBind();
}
//I add my checkbox in the last row using this
foreach (GridViewRow row in ValidateSubject.Rows)
{
check = row.Cells[row.Cells.Count - 1].Controls[0] as CheckBox;
check.Enabled = true;
}
}
protected void ValidateSubject_Click(object sender, EventArgs e)
{
if(check.Checked)
{
//This condition here is I want to change the Status when check to validated.
}
}
}
in my code behind using session I bind all the data in DataTable(FirstPage);
DataSet ds = connector.ExecuteQuery(query);
DataTable dt = dt.Table[0];
dt.DataBind();
Session["SubjectList"] = dt;
