-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcarsDetail.aspx.cs
More file actions
51 lines (49 loc) · 1.55 KB
/
carsDetail.aspx.cs
File metadata and controls
51 lines (49 loc) · 1.55 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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class carsDetail : System.Web.UI.Page
{
string strCon = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ConnectionString;
SqlConnection conn;
SqlCommand comm;
int id=0;
protected void Page_Load(object sender, EventArgs e)
{
id =Convert.ToInt32(Request.QueryString["id"]);
string sql = String.Format("select * from gd_cars where id='{0}'", id);
using (conn = new SqlConnection(strCon))
{
conn.Open();
comm = new SqlCommand(sql, conn);
SqlDataReader reader = comm.ExecuteReader();
try
{
if (reader.Read())
{
Title.Text = reader.GetString(1);
Introduction.Text = reader.GetString(2);
Content.Text = reader.GetString(3);
Price.Text = reader.GetString(4);
Time.Text = string.Format(reader.GetDateTime(5).ToString());
}
}
catch (System.Data.SqlTypes.SqlNullValueException ex)
{
Response.Write(ex.Message);
}
finally
{
}
reader.Close();
}
}
protected void aliPayBtn_Click(object sender, EventArgs e)
{
Response.Redirect("./alipay/default.aspx?id="+id);
}
}