private void LoadContents() { WhatsNewTableAdapter index = new WhatsNewTableAdapter(); DataTable whats = index.GetWhatsNewByPage(UPager.CurrentIndex, UPager.PageSize); if (whats.Rows.Count > 0) { gvWhatsNew.DataSource = whats; gvWhatsNew.DataBind(); if (gvWhatsNew.Columns.Count > 0) gvWhatsNew.Columns[0].Visible = false; else { gvWhatsNew.HeaderRow.Cells[1].Visible = false; gvWhatsNew.HeaderRow.Cells[4].Visible = false; gvWhatsNew.HeaderRow.Cells[6].Visible = false; gvWhatsNew.HeaderRow.Cells[7].Visible = false; foreach (GridViewRow gvr in gvWhatsNew.Rows) { gvr.Cells[1].Visible = false; gvr.Cells[4].Visible = false; gvr.Cells[6].Visible = false; gvr.Cells[7].Visible = false; } } UPager.ItemCount = Double.Parse(whats.Rows[0]["TotalRows"].ToString()); } }
protected void Page_Load(object sender, EventArgs e) { WhatsNewTableAdapter contAdptr = new WhatsNewTableAdapter(); int id = int.Parse(Request.QueryString["Id"]); WhatsNew.WhatsNewDataTable data = contAdptr.GetData(id); WhatsNew.WhatsNewRow dr = data.Rows[0] as WhatsNew.WhatsNewRow; lbldata.Text = dr.Data; }
protected void gvContents_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridView gv = sender as GridView; GridViewRow row = gv.Rows[e.RowIndex]; int? id = Int32.Parse(row.Cells[1].Text); WhatsNewTableAdapter index = new WhatsNewTableAdapter(); if (id != null & id > 0) { index.Delete(id); LoadContents(); } }
protected void btnUpload_Click(object sender, EventArgs e) { WhatsNewTableAdapter WNAdapter = new WhatsNewTableAdapter(); WNAdapter.Insert(ddlcatagory.SelectedValue, txtTitle.Text, edtData.Content, DateTime.Now); Server.Transfer("WhatsNew.aspx"); }