public void BindType() { dropType.DataSource = NewsTypeBll.GetAllNewsType(); dropType.DataTextField = "TypeName"; dropType.DataValueField = "NewsTypeId"; dropType.DataBind(); dropType.Items.Insert(0, "--请选择新闻类型--"); }
public void BindDrop() { dropNewsType.DataSource = NewsTypeBll.GetAllNewsType(); dropNewsType.DataTextField = "TypeName"; dropNewsType.DataValueField = "NewsTypeId"; dropNewsType.DataBind(); dropNewsType.Items.Insert(0, "显示全部"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindType(); txtTimer.Value = DateTime.Now.ToString("yyyy-MM-dd"); if (Request.QueryString["typeId"] != null && Request.QueryString["typeId"] != "") { int typeId = Convert.ToInt32(Request.QueryString["typeId"]); List <NewsType> list = NewsTypeBll.GetNewsTypebyId(typeId); if (list.Count > 0) { dropType.SelectedValue = Request.QueryString["typeId"]; } } else { if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null) { int id = Convert.ToInt32(Request.QueryString["id"]); List <Model.News> list = NewsBll.GetNewsbyId(id); if (list.Count > 0) { txtTitle.Text = list[0].Title; txtTimer.Value = list[0].CreateTime; txtImgUrl.Text = list[0].ImgUrl; dropType.SelectedValue = list[0].NewsTypeId.ToString(); fck_intro.Value = list[0].Intro; fck_detail.Value = list[0].Details; chkShow.Checked = Convert.ToBoolean(list[0].IsShow); chkTop.Checked = Convert.ToBoolean(list[0].IsTop); chkIndex.Checked = Convert.ToBoolean(list[0].IndexShow); hfId.Value = id.ToString(); } } } } }