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["DownloadId"] != null)
        {
            int downloadId = Convert.ToInt32(Request.QueryString["DownloadId"]);
            dtDownloads = taDownloads.SelectDownloadbyDownloadId(downloadId);

            if (dtDownloads.Rows.Count > 0)
            {
                ddlCategory.Items.FindByValue(dtDownloads[0].CategoryId.ToString()).Selected = true;
                txtTitle.Text = dtDownloads[0].Title.ToString();
                lblUpload.Text = dtDownloads[0].Upload.ToString();
                Image1.ImageUrl = "~/thumbnail.aspx?Image=Images/Downloads/" + lblUpload.Text + "&size=100";
                txtExternalLink.Text = dtDownloads[0].ExternalLink.ToString();
            }
            else
            {
                lblMsg.Text = "No Record Found";
                btnEdit.Visible = false;
                return;
            }

        }
        else
        {
            lblMsg.Text = "No Record Found";
            btnEdit.Visible = false;
            return;
        }
    }
Example #2
0
    private void BindData()
    {
        if (Request.QueryString["CategoryId"] != null)
        {
            int categoryId = Convert.ToInt32(Request.QueryString["CategoryId"]);
            dtDownloads = taDownloads.SelectDownloadbyCategoryId(categoryId);
            ddlCategory.Items.FindByValue(categoryId.ToString()).Selected = true;
        }
        else
            dtDownloads = taDownloads.SelectAllDownloads();

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