protected void gvResult_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Cells[3].Visible = false; if (e.Row.RowType == DataControlRowType.DataRow) { // If option selected is the wrong answer. if (e.Row.Cells[2].Text.Equals("No")) { // Declare a Hyper link HyperLink the_url = new HyperLink(); // Pass the related topic url to the hyperlink. the_url.NavigateUrl = "Topic.aspx?ID=" + e.Row.Cells[3].Text + "&lessonid=" + ViewState["lessonID"].ToString(); TopicBL topicBL = new TopicBL(); // Retrieve topic data. DataTable topic = topicBL.GetTopicByID(Convert.ToInt32(e.Row.Cells[3].Text)); // Pass topic title to URL. if (topic.Rows.Count > 0) { the_url.Text = topic.Rows[0].Field <string>("Title"); } // Add URL to grid view. e.Row.Cells[4].Controls.Add(the_url); } } }
/// <summary> /// Bind example tables to gridviews. /// </summary> private void BindExampleTable() { // Create instance of Topic business logic. TopicBL topicBL = new TopicBL(); // Get the first example table DataTable table = topicBL.GetExampleTable(TopicID); gvTableExample.DataSource = table; gvTableExample.DataBind(); DataTable topic = topicBL.GetTopicByID(TopicID); // If the topic has a second example query, populate the second example table. if (topic.Rows[0].Field <string>("ExampleQuery2") != null) { DataTable table2 = topicBL.GetExampleTable2(TopicID); gvTableExample2.DataSource = table2; gvTableExample2.DataBind(); } // If the topic has a third example query, populate the third example table. if (topic.Rows[0].Field <string>("ExampleQuery3") != null) { DataTable table3 = topicBL.GetExampleTable3(TopicID); gvTableExample3.DataSource = table3; gvTableExample3.DataBind(); } }
/// <summary> /// Binds topic title and topic description. /// </summary> /// <param name="topicID"></param> private void BindContent(int topicID) { TopicBL topicBL = new TopicBL(); DataTable table = topicBL.GetTopicByID(topicID); lblLessonTitle.Text = table.Rows[0].Field <string>("Title"); lblTopicText.Text = table.Rows[0].Field <string>("Text"); lblTopicText2.Text = table.Rows[0].Field <string>("Text2"); }
protected void Page_Load(object sender, EventArgs e) { // Check if user has authorization. if (!Context.User.Identity.IsAuthenticated && Context.Session["UserID"] != null) { Response.Redirect("Login.aspx"); } // Reference User ID UserID = Convert.ToInt32(Context.Session["UserID"]); // Validate Query strings. Validation(); // Reference values stored in query strings. TopicID = Convert.ToInt32(Request.QueryString["ID"]); LessonID = Convert.ToInt32(Request.QueryString["lessonid"]); // Create example tables according to the topic ID. BindExampleTable(); // Create an instance of the Topic business logic TopicBL topicBL = new TopicBL(); // Get the topic record by its ID from the database. DataTable dataTable = topicBL.GetTopicByID(TopicID); // Pass the video link to the Iframe instance. videoSource.Src = dataTable.Rows[0].Field <string>("VideoLink"); // Get text content to populate the Topic page. BindContent(TopicID); if (!IsPostBack) { // Insert record if it doesn't exist in the linking table between user and topic. userTopicBL = new UserTopicBL(); userTopicBL.InsertRecord(UserID, TopicID); } }
/// <summary> /// Creates links in grid view. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvResult_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Cells[3].Visible = false; e.Row.Cells[4].Visible = false; if (e.Row.RowType == DataControlRowType.DataRow) { // If the answer of this row is wrong provide link to topic. if (e.Row.Cells[2].Text.Equals("No")) { HyperLink the_url = new HyperLink(); the_url.NavigateUrl = "Topic.aspx?ID=" + e.Row.Cells[4].Text + "&lessonid=" + e.Row.Cells[3].Text; TopicBL topicBL = new TopicBL(); DataTable topic = topicBL.GetTopicByID(Convert.ToInt32(e.Row.Cells[4].Text)); if (topic.Rows.Count > 0) { the_url.Text = topic.Rows[0].Field <string>("Title"); } e.Row.Cells[5].Controls.Add(the_url); } } }
public ActionResult GetTopicByID(int ID) { TopicBL topicBL = new TopicBL(); return(Json(topicBL.GetTopicByID(ID), JsonRequestBehavior.AllowGet)); }