-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAllPoCustQuery.aspx.cs
More file actions
53 lines (47 loc) · 1.72 KB
/
Copy pathAllPoCustQuery.aspx.cs
File metadata and controls
53 lines (47 loc) · 1.72 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;//for DB connectivity: SQL Connection
using System.Configuration;//for web.config
namespace CRM_Final_Project
{
public partial class AllPoCusttQuery : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
connect();
}
}
public void connect()
{
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbcon"].ConnectionString);//create DB Connection
con.Open();//open DB connection
string qry = "select * from PotentialCustomer ";//SQL Query
SqlCommand cmd = new SqlCommand(qry, con);//Send Query for execution
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)//If data Meet in dr
{
GridView1.DataSource = dr;//GridView Will take data from dr
GridView1.DataBind();//Binding the Grid fields with DB
}
}
catch (SqlException ex)//Exception for catching error By using SqlException class
{
Response.Write(ex);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Button btn = (Button)sender; //for binding complaint id
string args = btn.CommandArgument;
Response.Redirect("ReplyonPoCustQuery.aspx?PCustQueryId=" + args);
}
}
}