-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowGridViewPagingDynamic.aspx.cs
82 lines (78 loc) · 2.85 KB
/
showGridViewPagingDynamic.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Data;
public partial class showGridViewPagingDynamic : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("ljhkmjhgkh");
DataTable dtTutorial = new DataTable();
// GridView1.Visible = true;
// GridView1.AutoGenerateColumns = false;
// GridView1.AllowPaging = true;
//// GridView1.OnPageIndexChanging = "OnPageIndexChanging";
// GridView1.PageSize = 10;
SqlConnection con;
using (con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnStringDb"].ToString()))
{
SqlCommand cmd = new SqlCommand("Select id,Topic,Description,link FROM Tutorial Where UniversityName='CUET' AND Department='CSE' AND Subject='Algorithm'", con);
dtTutorial.Columns.Add("Topic");
dtTutorial.Columns.Add("Description");
dtTutorial.Columns.Add("Visit");
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
DataRow dr = dtTutorial.NewRow();
dr["Topic"] = rdr["Topic"];
dr["Description"] = rdr["Description"];
dr["Visit"] = rdr["id"];
dtTutorial.Rows.Add(dr);
}
con.Close();
}
GridView1.DataSource = dtTutorial;
GridView1.DataBind();
foreach (GridViewRow gr in GridView1.Rows)
{
HyperLink hp = new HyperLink();
//hp.Text = gr.Cells[2].Text;
hp.Text = "Click here";
hp.NavigateUrl = "~/Details.aspx?id=" + gr.Cells[2].Text;
gr.Cells[2].Controls.Add(hp);
}
}
//private void BindGrid()
//{
// string constr = WebConfigurationManager.ConnectionStrings["ConnStringDb"].ConnectionString;
// using (SqlConnection con = new SqlConnection(constr))
// {
// using (SqlCommand cmd = new SqlCommand("Select id,Topic,Description,link FROM Tutorial"))
// {
// using (SqlDataAdapter sda = new SqlDataAdapter())
// {
// cmd.Connection = con;
// sda.SelectCommand = cmd;
// using (DataTable dt = new DataTable())
// {
// sda.Fill(dt);
// GridView1.DataSource = dt;
// GridView1.DataBind();
// }
// }
// }
// }
//}
//protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
//{
// GridView1.PageIndex = e.NewPageIndex;
// this.BindGrid();
//}
}