protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["PlaceName"] != null) { string mainconn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection sqlConnection = new SqlConnection(mainconn); string sqlquery = "select * from [dbo].[PlaceInfo] where PlaceName=@PlaceName"; SqlCommand sqlCommand = new SqlCommand(sqlquery, sqlConnection); sqlConnection.Open(); sqlCommand.Parameters.AddWithValue("@PlaceName", Request.QueryString["PlaceName"]); SqlDataReader sdr = sqlCommand.ExecuteReader(); if (sdr.HasRows) { sdr.Close(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = sqlCommand; DataSet ds = new DataSet(); da.Fill(ds); Label1.Text = ds.Tables[0].Rows[0]["DistrictID"].ToString(); Label3.Text = "Nearby Place in " + ds.Tables[0].Rows[0]["PlaceName"].ToString(); DataList2.DataSource = ds; DataList2.DataBind(); blog(); hotel(); Restaurent(); mostpopularplace(); } else { Response.Redirect("Home.aspx"); } sqlConnection.Close(); } else { Response.Redirect("Home.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { addBasket = Request.QueryString["addBasket"]; writer = Request.QueryString["yazar"]; if (Page.IsPostBack == false) { Label3.Text = writer; SqlCommand cd = new SqlCommand("select *from Tbl_Kitaplar where KitapYazar=@p1", conn.connection()); cd.Parameters.AddWithValue("@p1", writer); SqlDataReader dr = cd.ExecuteReader(); DataList2.DataSource = dr; DataList2.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null) { WebMessageBox.Show("对不起,您还没登录!", "login(会员)/Default.aspx"); } else { DataList1.DataSource = op.SelectMember(Session["username"].ToString()); DataList1.DataBind(); DataList2.DataSource = op.SelectMemberAddress(Session["username"].ToString()); DataList2.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataList2.DataSource = HienThiDanhMucSanPham(); DataList2.DataBind(); pager.DataSource = HienThiDanhMucSanPham().DefaultView; pager.BindToControl = DataList2; DataList2.DataSource = pager.DataSourcePaged; } }
protected void ImageButton5_Click(object sender, ImageClickEventArgs e) { string sSql = "select * from Goods where title like '%" + TextBox4.Text.Trim() + "%'"; SQL s = new SQL(); DataSet ds = s.DSSearch(sSql); // s.DSSearch(sSql); PagedDataSource pds = new PagedDataSource(); //初始化PagedDataSource实例,主要用做DataList1的分页使用 pds.AllowPaging = true; //允许分页 pds.PageSize = 15; //每页显示10条 pds.DataSource = ds.Tables[0].DefaultView; //将检索出的ds数据集绑定给PagedDataSource实例pds DataList2.DataSource = pds; //将pds内容最终绑定给DataList1,呈现到界面中 DataList2.DataBind(); }
public void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "viewsubcat") { int catid = Convert.ToInt32(e.CommandArgument); Session["catid"] = catid; string qry = "select * from SubcategoryTable where pr_catid = '" + catid + "'"; con.Open(); SqlCommand cmd = new SqlCommand(qry, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); DataList2.DataSource = ds; DataList2.DataBind(); con.Close(); string qry2 = "select count(pr_subid) from SubcategoryTable where pr_catid = '" + catid + "'"; con.Open(); SqlCommand cmd2 = new SqlCommand(qry2, con); SqlDataReader dr = cmd2.ExecuteReader(); dr.Read(); int count = Convert.ToInt32(dr[0]); if (count > 0) { Panel1.Visible = false; } else { Panel1.Visible = true; } con.Close(); } if (e.CommandName == "delcat") { int catid = Convert.ToInt32(e.CommandArgument); string qry1 = "delete from CategoryTable where pr_catid ='" + catid + "'"; string qry2 = "delete from SubcategoryTable where pr_catid = '" + catid + "'"; SqlCommand cmd1 = new SqlCommand(qry1, con); SqlCommand cmd2 = new SqlCommand(qry2, con); con.Open(); cmd1.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); con.Close(); Response.Redirect("../ADMIN/AdminHome.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { var list = (List <CheckOutLogic>)Session["Info"]; var shipList = (List <ShippingInfoLogic>)Session["shipInfo"]; DataList1.DataSource = list; DataList1.DataBind(); DataList2.DataSource = shipList; DataList2.DataBind(); DataList3.DataSource = shipList; DataList3.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { conne = new Connection(); DataList1.DataSource = conne.showmatches(); DataList1.DataBind(); string tintin = null; tintin = Request.QueryString["macid"]; if (tintin != null) { DataList2.DataSource = conne.Macinfo(tintin); DataList2.DataBind(); } }
protected void LinkButton1_Click(object sender, EventArgs e) { int a = cs.insert("insert into replay(rid,uid,apid,replay)values('4','1','1','" + TextBox1.Text + "')"); TextBox1.Text = ""; Panel1.Visible = false; if (a > 0) { DataTable dt = cs.select("select u.name,u.photo,r.replay from replay r join userregistration u on r.uid=u.uid "); DataList2.Visible = true; DataList2.DataSource = dt; DataList2.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // SqlConnection con = new SqlConnection("data source=.;database=testdb;integrated security=SSPI"); string cs = ConfigurationManager.ConnectionStrings["dbcs"].ConnectionString; SqlConnection con = new SqlConnection(cs); con.Open(); SqlCommand cmd = new SqlCommand("select * from categories", con); DataList2.DataSource = cmd.ExecuteReader(); DataList2.DataBind(); getproducts(0); } }
protected void Page_Load(object sender, EventArgs e) { SqlCommand komut = new SqlCommand("Select * from Tbl_Tarifler where TarifDurum=0", bgl.baglanti()); SqlDataReader dr = komut.ExecuteReader(); DataList1.DataSource = dr; DataList1.DataBind(); SqlCommand komut2 = new SqlCommand("Select * from Tbl_Tarifler where TarifDurum=1", bgl.baglanti()); SqlDataReader dr2 = komut2.ExecuteReader(); DataList2.DataSource = dr2; DataList2.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { MySqlCommand komut = new MySqlCommand("select * from tarif where tarifdurum=0", bgl.baglanti()); MySqlDataReader dr = komut.ExecuteReader(); DataList1.DataSource = dr; DataList1.DataBind(); MySqlCommand komut2 = new MySqlCommand("select * from tarif where tarifdurum=1", bgl.baglanti()); MySqlDataReader dr2 = komut2.ExecuteReader(); DataList2.DataSource = dr2; DataList2.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataList2.DataSource = ProductSearch_DS(); DataList2.DataBind(); pager.DataSource = ProductSearch_DS().DefaultView; pager.BindToControl = DataList2; DataList2.DataSource = pager.DataSourcePaged; } }
private void goodsbind() { string sSql = "select * from goods where sort='" + Request["sort"].ToString() + "'"; SQL s = new SQL(); DataSet ds = s.DSSearch(sSql); // s.DSSearch(sSql); PagedDataSource pds = new PagedDataSource(); //初始化PagedDataSource实例,主要用做DataList1的分页使用 pds.AllowPaging = true; //允许分页 pds.PageSize = 15; //每页显示10条 pds.DataSource = ds.Tables[0].DefaultView; //将检索出的ds数据集绑定给PagedDataSource实例pds DataList2.DataSource = pds; //将pds内容最终绑定给DataList1,呈现到界面中 DataList2.DataBind(); }
public void DisplayNews() { DataTable dt1 = new DataTable(); dt1 = bus.ShowNews(); DataList1.DataSource = dt1; DataList1.DataBind(); DataTable dt2 = new DataTable(); dt2 = bus.ShowTopNews(); DataList2.DataSource = dt2; DataList2.DataBind(); }
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName.Equals("Click")) { int id = Convert.ToInt32(e.CommandArgument); String query = "select * from Product where Category = (select Categoryname from Category where Id = " + id + ")"; DataSet ds = new DataSet(); SqlDataAdapter adp = new SqlDataAdapter(query, con); adp.Fill(ds); DataList2.DataSource = ds; DataList2.DataBind(); } }
private void goods() { string sSql = "select a.*,isnull((select count(*) from orderdetail where bookid=a.id group by bookid),0) as xl from goods a order by xl desc "; SQL s = new SQL(); DataSet ds = s.DSSearch(sSql); // s.DSSearch(sSql); PagedDataSource pds = new PagedDataSource(); //初始化PagedDataSource实例,主要用做DataList1的分页使用 pds.AllowPaging = true; //允许分页 pds.PageSize = 15; //每页显示10条 pds.DataSource = ds.Tables[0].DefaultView; //将检索出的ds数据集绑定给PagedDataSource实例pds DataList2.DataSource = pds; //将pds内容最终绑定给DataList1,呈现到界面中 DataList2.DataBind(); }
void VideosBindGrid2() { SqlConnection con = new SqlConnection(constr); con.Open(); SqlCommand cmd = new SqlCommand("select * from CreateCourseTable where coursetype='development' ", con); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); DataTable videodt = new DataTable(); videodt.Load(dr); DataList2.DataSource = videodt; DataList2.DataBind(); con.Close(); }
public void BindDataList2() { DataTable dtTable = new DataTable(); DataColumn[] dataColumns = new DataColumn[8]; String[] test = { "order_id", "BookID", "picUrl", "BookName", "order_price", "order_date", "isPay", "BookUrl" }; for (int k = 0; k < test.Length; k++) { dataColumns[k] = new DataColumn(test[k]); dtTable.Columns.Add(dataColumns[k]); } String sql = "select Cart_Goods.order_id,BookID,Goods_Info.picUrl,BookName,order_price,order_date,isPay from Cart_Goods,Cart_Info,Goods_Info where Cart_Goods.order_id=Cart_Info.order_id and order_bookid=BookID and Cart_Info.UID=@uid order by order_id"; SqlParameter[] parameters = { new SqlParameter("@uid", Session["uid"].ToString()) }; DataSet ds = operate.GetTable(sql, parameters); DataRow row; int i = 0; foreach (DataRow drRow in ds.Tables[0].Rows) { row = dtTable.NewRow(); row["order_id"] = ds.Tables[0].Rows[i][0].ToString(); row["BookID"] = ds.Tables[0].Rows[i][1].ToString(); row["picUrl"] = ds.Tables[0].Rows[i][2].ToString(); row["BookName"] = ds.Tables[0].Rows[i][3].ToString(); row["order_price"] = ds.Tables[0].Rows[i][4].ToString(); row["order_date"] = ds.Tables[0].Rows[i][5].ToString(); row["isPay"] = Convert.ToBoolean(ds.Tables[0].Rows[i][6]); if (ds.Tables[0].Rows[i][6].ToString() == "True") { row["isPay"] = "已付款"; } else { row["isPay"] = "未付款"; } row["BookUrl"] = "../Goods/Detail.aspx?id=" + ds.Tables[0].Rows[i][1].ToString(); i++; dtTable.Rows.Add(row); } DataList2.DataSource = dtTable.DefaultView; DataList2.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { lbl_islem.Visible = false; id = Request.QueryString["id"]; SqlCommand cd = new SqlCommand("select *from Tbl_Kitaplar where KitapId=@p1", conn.connection()); cd.Parameters.AddWithValue("@p1", id); SqlDataReader dr = cd.ExecuteReader(); while (dr.Read()) { lb_bookname.Text = dr[1].ToString(); if (dr[7].ToString() != "-") { lb_oriname.Visible = true; lb_oriname.Text = dr[7].ToString(); } if (dr[3].ToString() != "-") { Panel2.Visible = true; lb_cevirmen.Text = dr[3].ToString(); } lb_yazar.Text = dr[2].ToString(); lb_fiyat.Text = dr[4].ToString(); lb_icerik.Text = dr[10].ToString(); lb_yayinevi.Text = dr[5].ToString(); lb_baski.Text = dr[12].ToString().Substring(0, 10); lb_baskisayisi.Text = dr[13].ToString(); lb_sayfa.Text = dr[9].ToString(); lb_boyut1.Text = dr[18].ToString(); lb_boyut2.Text = dr[19].ToString(); lb_isbn.Text = dr[14].ToString(); lb_dil.Text = dr[15].ToString(); lb_cilt.Text = dr[16].ToString(); lb_kagit.Text = dr[17].ToString(); lb_puan.Text = dr[8].ToString(); Image2.ImageUrl = dr[6].ToString(); } conn.connection().Close(); SqlCommand cdCommand = new SqlCommand("select *from Tbl_Yorumlar where KitapId=@p1 and YorumOnay=1", conn.connection()); cdCommand.Parameters.AddWithValue("@p1", id); SqlDataReader drCommand = cdCommand.ExecuteReader(); DataList2.DataSource = drCommand; DataList2.DataBind(); conn.connection().Close(); }
protected void Page_Load(object sender, EventArgs e) { kategoriid = Request.QueryString["kategori_id"]; baglanti.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/filmler.mdb"); baglanti.Open(); OleDbCommand komut = new OleDbCommand("select * from film where tur_id=@kategoriid"); komut.Parameters.AddWithValue("@kategoriid", kategoriid); komut.Connection = baglanti; OleDbDataReader dr2 = komut.ExecuteReader(); DataList2.DataSource = dr2; DataList2.DataBind(); baglanti.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string[] filePaths = Directory.GetFiles(Server.MapPath("~/images/")); List <ListItem> files = new List <ListItem>(); foreach (string filePath in filePaths) { string fileName = Path.GetFileName(filePath); files.Add(new ListItem(fileName, "~/images/" + fileName)); } DataList2.DataSource = files; DataList2.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //获取教练信息 DataList1.DataSource = data.GetDataReader("select top 10 * from JiaoLian order by id desc "); DataList1.DataBind(); DataList2.DataSource = data.GetDataReader("select top 6 * from KeCheng order by id desc "); DataList2.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = Int32.Parse(Request.QueryString["id"].Trim()); StringBuilder sb = new StringBuilder(); sb.Append("Id="); sb.Append(id); ds = room.GetList(sb.ToString()); DataList2.DataSource = ds; DataList2.DataBind(); DataList1.DataSource = ds; DataList1.DataBind(); } }
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { // Tin liên quan//Download source code tại Sharecode.vn // Đay là sự kiện trong datalist khi cứ load cái này lên thì ta sẽ có thể lấy đc cái mã hdf_IDNews để hiển thị tin liên quan mà không có cái bản tin hiện hành mà mình đang xem HiddenField hdf_ID_news = (HiddenField)e.Item.FindControl("hdf_IDNews"); // Tạo ra một hiddenfild dể lưu trữ dữ liệu mà tìm trong Datalist 1 cái hdf_IDNews gán cho hdf_ID_news dữ liệu là id bản tin int id = Convert.ToInt32(hdf_ID_news.Value); TinMoiNhat a = new TinMoiNhat(); DataTable dtb = a.TinDaDang(id); // Phương thức này tìm ra những bản tin đã đăng mà không có cái bản tin hiện hành chính là id trong a.TinDaDang(id); DataList2.DataSource = dtb; DataList2.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { SqlCommand komut = new SqlCommand("select *from Tbl_Yorumlar where YorumOnay=1 ", bgl.baglanti()); SqlDataReader dr = komut.ExecuteReader(); DataList1.DataSource = dr; DataList1.DataBind(); Panel1.Visible = false; Panel2.Visible = false; SqlCommand komut2 = new SqlCommand("select *from Tbl_Yorumlar where YorumOnay=0 ", bgl.baglanti()); SqlDataReader dr2 = komut2.ExecuteReader(); DataList2.DataSource = dr2; DataList2.DataBind(); }
void receberHistóricoMensagem() { SqlConnection conn = new SqlConnection(new ClsFuncoes().conexao); conn.Open(); string str = "SELECT SENDER,MENSAGEM, DATA_MENSAGEM FROM CHAT WHERE RECEIVER ='" + Session["grupo"] + "L" + "' ORDER BY ID_MENSAGEM DESC"; SqlCommand cmd1 = new SqlCommand(str, conn); SqlDataAdapter da = new SqlDataAdapter(cmd1); DataSet ds = new DataSet(); da.Fill(ds); DataList2.DataSource = ds; DataList2.DataBind(); conn.Close(); }
protected void Button1_command(object sender, CommandEventArgs e) { DataTable dt = ds.GetData("select count(*) from request where username='******' and r_username='******' "); if (Convert.ToInt32(dt.Rows[0][0]) == 0) { ds.UpdateData("insert into request values ('" + Session["username"].ToString() + "','" + e.CommandName + "' )"); } else { Label1.Visible = true; Label1.Text = "Request Allready Send."; } DataList2.DataBind(); }
protected void BindDataList1() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString); con.Open(); SqlCommand command = new SqlCommand("SELECT * from cmt where rsp_id=" + Session["recp_id"].ToString(), con); SqlDataAdapter da = new SqlDataAdapter(command); DataTable dt = new DataTable(); da.Fill(dt); DataList2.DataSource = dt; DataList2.DataBind(); con.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { dlNews.DataSource = data.GetDataReader("select top 10 * from dbo.News order by Addtime desc "); dlNews.DataBind(); DataList2.DataSource = data.GetDataReader("select top 8 * from ShangPinInfo order by ShangPinDate desc "); DataList2.DataBind(); DataList1.DataSource = data.GetDataReader("select top 8 * from ShangPinInfo order by ShangPinClick desc "); DataList1.DataBind(); } }