私はDropDownListBoxを2つ持っています.1つはddlDay、もう1つはddlMonthです。その名前が示すように、ddlDayの値は01から31(動的ではない)で、ddlMonthの値は01から12です。これらの値は動的に設定されません。DropDownListバインディングの問題
ページが読み込まれると、dbから値を取得しています。値によっては、値ddlDay.SelectedItem.Value = the value from the db to set
を使用して項目を選択しています。
以下に示すコードは、If Not Page.IsPostback Then...
の幸運のない文でテストされました。
ただし、初めてページを読み込んだ場合は何も起こりません。ページをリフレッシュしてポストバックが発生すると、値が正しくバインドされます。
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
loadInterview()
End Sub
Private Sub loadInterview()
If Request.QueryString("iID") = "" Or Request.QueryString("iID") Is Nothing Then
Response.Redirect("interviews_list.aspx")
Else
Dim int As New hh.Interviews
int = hh.Interviews.ReturnSingleInterview(Request.QueryString("iID"))
ddlDay.SelectedItem.Value = int.InterviewDate.Day.ToString("00")
ddlMonth.SelectedItem.Value = int.InterviewDate.Month.ToString("00")
txtYear.Text = int.InterviewDate.Year
txtPerson.Text = int.InterviewPerson
txtTitle.Text = int.InterviewTitle
txtText.Text = int.InterviewText
End If
nitpick ... "int"は他の言語のIntegerの共通予約識別子で、混乱を減らすために変更することを検討します。 hh名前空間とは何ですか? –
ありがとうございました、警告のおかげでもっと意味のある言葉に変更しました。はいhhは名前空間です... –