public void DataBind(string key = "") { DataTable dt = new DataTable(); if (!string.IsNullOrEmpty(Request.QueryString["type"])) { int type = DataConverter.CLng(Request.QueryString["type"]); dt = B_ADZone.ADZone_ByCondition(" Where ShowTime=" + type + " order by ID desc"); Egv.DataKeyNames = new string[] { "ZoneID" }; } else { string adname = this.ViewState["AdName"].ToString(); if (string.IsNullOrEmpty(adname)) { dt = B_A.SelectAdbuy(); Egv.DataKeyNames = new string[] { "ID" }; } else { dt = B_ADZone.ADZone_ByCondition(" Where ShowTime like @adname order by ID desc", new SqlParameter[] { new SqlParameter("adname", "%" + adname + "%") }); Egv.DataKeyNames = new string[] { "ID" }; } } Egv.DataSource = dt; Egv.DataBind(); }
private void RepNodeBind() { string adname = this.ViewState["AdName"].ToString(); if (string.IsNullOrEmpty(adname)) { DataTable da = B_ADZone.ADZone_GetAll(); if (da.Rows.Count > 0) { this.nocontent.Style["display"] = "none"; this.GridView1.DataSource = da; GridView1.DataKeyNames = new string[] { "ZoneID" }; this.GridView1.DataBind(); this.GridView1.Visible = true; } else { this.nocontent.Style["display"] = ""; this.GridView1.Visible = false; } } else { DataTable da = B_ADZone.ADZone_ByCondition(" Where ZoneName like '%" + adname + "%'"); if (da.Rows.Count != 0) { this.nocontent.Style["display"] = "none"; this.GridView1.DataSource = da; GridView1.DataKeyNames = new string[] { "ZoneId" }; this.GridView1.DataBind(); this.GridView1.Visible = true; } else { this.nocontent.Style["display"] = ""; this.GridView1.Visible = false; } } }