예제 #1
0
 protected void SelectCategories()
 {
     dtCategory = taCategory.SelectAllSectionCategories();
     ddlCategory.DataSourceID = null;
     ddlCategory.DataSource = dtCategory;
     ddlCategory.DataTextField = dtCategory.Columns[1].ToString();
     ddlCategory.DataValueField = dtCategory.Columns[0].ToString();
     ddlCategory.DataBind();
     ddlCategory.Items.Insert(0, new ListItem("Please Select", ""));
 }
예제 #2
0
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lblCategoryId = (Label)e.Row.FindControl("lblCategoryId");
            dtCategory = taCategory.SelectSectionCategorybyCategoryId(Convert.ToInt32(lblCategoryId.Text));
            if (dtCategory.Rows.Count > 0)
                lblCategoryId.Text = dtCategory[0].CategoryName.ToString();
            else
                lblCategoryId.Visible = false;

            LinkButton btnDel = (LinkButton)e.Row.FindControl("lbtnDelete");
            btnDel.Attributes.Add("OnClick", "return confirm('Are you sure to delete this record?');");
        }
    }
 private void BindData()
 {
     dtCategory = taCategory.SelectAllSectionCategories();
     if (dtCategory.Rows.Count > 0)
     {
         GridView1.DataSourceID = null;
         GridView1.DataSource = dtCategory;
         GridView1.DataBind();
     }
     else
     {
         lblMsg.Text = "No record found";
         return;
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
            return;

        if (Request.QueryString["ID"] != null)
        {
            if (Request.QueryString["ID"] == "True")
            {
                lblMsg.Visible = true;
                lblMsg.Text = "Successfully Edited";
            }
        }

        if (Request.QueryString["CategoryId"] != null)
        {
            int CategoryId = Convert.ToInt32(Request.QueryString["CategoryId"]);
            dtCategory = taCategory.SelectSectionCategorybyCategoryId(CategoryId);

            if (dtCategory.Rows.Count > 0)
            {
                DataRow row = dtCategory.Rows[0];
                txtCategory.Text = row["CategoryName"].ToString();
            }
            else
            {
                lblMsg.Text = "No Record Found";
                btnEdit.Visible = false;
                return;
            }
        }
        else
        {
            lblMsg.Text = "No Record Found";
            btnEdit.Visible = false;
            return;
        }
    }