コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                AuthorController ac = new AuthorController();
                //Check if no paratmeter exist, redirect to list page.
                Uri    myUri    = new Uri(Request.Url.ToString());
                string AuthorID = HttpUtility.ParseQueryString(myUri.Query).Get("ID");
                if (AuthorID == null)
                {
                    Response.Redirect("/UserControl/Template/Authors/ListAuthor.aspx");
                }
                ac.GetAuthor(int.Parse(AuthorID));
                txtAuthorName.Text     = ac.AuthorName;
                txtAuthorJobTitle.Text = ac.AuthorJobTitle;
                txtAuthorAddress.Text  = ac.AuthorAddress;
                txtAuthorEmail.Text    = ac.AuthorEmail;
                txtAuthorWebsite.Text  = ac.AuthorWebsite;
                lblFileUploadAuthorPicturePath.Text = ac.AuthorPicture;
                txtAuthorLinkedIn.Text      = ac.AuthorLinkedIn;
                txtAuthorFacebook.Text      = ac.AuthorFacebook;
                txtAuthorTwitter.Text       = ac.AuthorTwitter;
                txtAuthorInstagram.Text     = ac.AuthorInstagram;
                ddlLanguageId.SelectedValue = ac.LanguageID.ToString();

                LanguageController lc = new LanguageController();
                ddlLanguageId.DataSource     = lc.GetLanguages();
                ddlLanguageId.DataTextField  = "LanguageTitle";
                ddlLanguageId.DataValueField = "LanguageID";
                ddlLanguageId.DataBind();
                ddlLanguageId.Items.Insert(0, new ListItem("Select Language", "0"));
            }
        }