Code Behind Page Page /Controls/UserSelectedQuestion.ascx.cs (C#)
Used by Page /Controls/UserSelectedQuestion.ascx (C#)
1: using System;  
2: using System.Collections.Generic;  
3: using System.Web.UI;  
4: using System.Web.UI.WebControls;  
5: using Microsoft.ApplicationBlocks.Data;  
6: using QuizNetOnline.Logic;  
7:   
8: namespace QuiznetOnline.Web.UI.Controls  
9: {  
10:     public partial class UserSelectedQuestion : UserControl  
11:     {  
12:   
13:         public List<Question> DeletedQuestions { get; set; }  
14:   
15:         public GridView GridSelected  
16:         {  
17:             set { grdSelected = value; }  
18:             get { return grdSelected; }  
19:         }  
20:         protected void Page_Load(object sender, EventArgs e)  
21:         {  
22:             if (!Page.IsPostBack)  
23:             {  
24:                 ReloadGrid();      
25:             }  
26:         }  
27:   
28:   
29:         public void ReloadGrid()  
30:         {  
31:             UserFavourite userFavourite=new UserFavourite();  
32:             List<Question> userFavourites = userFavourite.GetUserFavourites(new SqlWrapper(),0, ((UserWeb)Session["userWeb"]).UserName);  
33:   
34:             grdSelected.DataSource = userFavourites;  
35:             grdSelected.DataBind();  
36:         }  
37:   
38:         protected void grdSelected_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)  
39:         {  
40:             if ((e.Row.RowType == DataControlRowType.Header))  
41:             {  
42:                 //adding an attribut for onclick event on the check box in the hearder and passing the ClientID of the Select All checkbox  
43:                 ((CheckBox)e.Row.FindControl("cbSelectAll")).Attributes.Add("onclick", "javascript:SelectAll('" + e.Row.FindControl("cbSelectAll").ClientID + "')");  
44:             }  
45:         }  
46:   
47:         protected void grdSelected_PageIndexChanging(object sender, GridViewPageEventArgs e)  
48:         {  
49:             grdSelected.PageIndex = e.NewPageIndex;  
50:             grdSelected.DataBind();  
51:         }  
52:   
53:         protected void cmdDelete_Click(object sender, EventArgs e)  
54:         {  
55:             List<Question> deletedQuestions=new List<Question>();  
56:             foreach (GridViewRow row in grdSelected.Rows)  
57:             {  
58:                 CheckBox chk = (CheckBox) row.FindControl("chkDelete");  
59:                 if(chk.Checked)  
60:                 {  
61:                     Question question=new Question();  
62:                     question.LoadQuestion(Convert.ToInt32(grdSelected.DataKeys[row.RowIndex].Value), new SqlWrapper());  
63:                     deletedQuestions.Add(question);  
64:                 }  
65:             }  
66:   
67:             DeletedQuestions = deletedQuestions;  
68:             OnBubbleClick(e);  
69:         }  
70:   
71:         public event EventHandler BubbleClick;  
72:         public void OnBubbleClick(EventArgs e)  
73:         {  
74:             if (BubbleClick != null)  
75:             {  
76:                 BubbleClick(this, e);  
77:             }  
78:         }    
79:     }  
80: }

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.