protected void SelectCategories()
 {
     dtCategory = taCategory.SelectAllDownloadCategories();
     ddlCategory.DataSourceID = null;
     ddlCategory.DataSource = dtCategory;
     ddlCategory.DataTextField = dtCategory.Columns["Title"].ToString();
     ddlCategory.DataValueField = dtCategory.Columns["CategoryId"].ToString();
     ddlCategory.DataBind();
     ddlCategory.Items.Insert(0, new ListItem("Please Select", ""));
 }
Exemplo n.º 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.SelectDownloadCategoryNamebyCategoryId(Convert.ToInt32(lblCategoryId.Text));
            if (dtCategory.Rows.Count > 0)
                lblCategoryId.Text = dtCategory[0].Title.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.SelectAllDownloadCategories();

        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.SelectDownloadCategorybyCategoryId(CategoryId);

            if (dtCategory.Rows.Count > 0)
            {
                txtCategory.Text = dtCategory[0].Title.ToString();
                lblImage.Text = dtCategory[0].Image.ToString();
                if (lblImage.Text != "")
                    Image1.ImageUrl = "~/thumbnail.aspx?Image=Images/DownloadCategoryImages/" + lblImage.Text + "&size=100";
                else
                    Image1.Visible = false;
            }
            else
            {
                lblMsg.Text = "No Record Found";
                btnEdit.Visible = false;
                return;
            }

        }
        else
        {
            lblMsg.Text = "No Record Found";
            btnEdit.Visible = false;
            return;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
            return;

        SelectCategories();

        if (Request.QueryString["ID"] != null)
        {
            if (Request.QueryString["ID"] == "True")
            {
                lblMsg.Visible = true;
                lblMsg.Text = "Successfully Edited";
            }
        }
        if (Request.QueryString["SubCategoryId"] != null)
        {
            int subCategoryId = Convert.ToInt32(Request.QueryString["SubCategoryId"]);
            dtSubCategory = taSubCategory.SelectDownloadCategorybyCategoryId(subCategoryId);

            if (dtSubCategory.Rows.Count > 0)
            {
                ddlCategory.Items.FindByValue(dtSubCategory[0].ParentId.ToString()).Selected = true;
                txtSubCategory.Text = dtSubCategory[0].Title.ToString();
            }
            else
            {
                lblMsg.Text = "No Record Found";
                btnEdit.Visible = false;
                return;
            }
        }
        else
        {
            lblMsg.Text = "No Record Found";
            btnEdit.Visible = false;
            return;
        }
    }
    private void BindData()
    {
        if (Request.QueryString["CategoryId"] != null)
        {
            int categoryId = Convert.ToInt32(Request.QueryString["CategoryId"]);
            dtSubCategory = taSubCategory.SelectDownloadSubCategoriesbyParentId(categoryId);
            ddlCategory.Items.FindByValue(categoryId.ToString()).Selected = true;
        }
        else
            dtSubCategory = taSubCategory.SelectAllDownloadSubCategories();

        if (dtSubCategory.Rows.Count > 0)
        {
            GridView1.DataSourceID = null;
            GridView1.DataSource = dtSubCategory;
            GridView1.DataBind();
        }
        else
        {
            lblMsg.Text = "No record found";
            return;
        }
    }