protected void Page_Load(object sender, EventArgs e) { UserPayee payee = (UserPayee)Session["PaymentInProgress_payee"]; Debug.WriteLine(payee.Nickname); Debug.WriteLine(payee.UserPayeeId); Debug.WriteLine(payee.UserId); // Validate that the UserId coming from UserPayee matches the one authenticated, else redirect to /Account/Default if (payee.UserId != User.Identity.GetUserId()) { Response.StatusCode = 403; Response.Redirect("/Account/Default"); } // Fill in Fields about the UserPayee txtNickname.Text = payee.Nickname; txtAccountNumber.Text = payee.PayeeAccountNumber; hdnExistingUserPayeeId.Value = payee.UserPayeeId; foreach (var fundingSources in FundingSourceDb.GetFundingSources(User.Identity.GetUserId()).ToList()) { ddlFundingSource.Items.Add(new ListItem { Text = fundingSources.Nickname.ToString(), Value = fundingSources.FundingSourceId.ToString() }); } }
protected void ddlFundingSource_DataBinding(object sender, EventArgs e) { DropDownList ddlFundingSource = (DropDownList)(sender); // Fill your ddl here (eg. ddl.Items.Add("abc", xyz"); // Make sure the value you are going to set the selected item to has been added foreach (var fundingSources in FundingSourceDb.GetFundingSources(User.Identity.GetUserId()).ToList()) { ddlFundingSource.Items.Add(new ListItem { Text = fundingSources.Nickname.ToString(), Value = fundingSources.FundingSourceId.ToString() }); } }
protected void CreateFundingSource_Click(object sender, EventArgs e) { FundingSource newFundingSource = new FundingSource(); newFundingSource.FundingSourceId = System.Guid.NewGuid().ToString().ToUpper(); newFundingSource.UserId = User.Identity.GetUserId(); newFundingSource.Type = ddlType.SelectedValue; newFundingSource.Nickname = txtNickname.Text; newFundingSource.AccountNumber = txtAccountNumber.Text; // Store into DB FundingSourceDb.InsertFundingSource(newFundingSource); // Refresh GridView GridView1.DataBind(); // Clear Values from Form ddlType.SelectedIndex = 0; txtNickname.Text = ""; txtAccountNumber.Text = ""; }