0
フォーカスがHTMLドロップダウンリストに入ると、Server Side LoadStudent()メソッドを呼び出すことができません。 Htmlとasp.netのロードサーバー側の関数onfocus
サーバーサイドのコーディング
Imports System.Data.SqlClient
Public Class FeeEntry
Public Sub LoadStudent()
MsgBox("Called")
Using cmd As New SqlCommand("SELECT StudentName FROM Student")
cmd.CommandType = CommandType.Text
cmd.Connection = con
'con.Open()
DropDownList1.DataSource = cmd.ExecuteReader()
DropDownList1.DataTextField = "StudentName"
DropDownList1.DataValueField = "StudentName"
DropDownList1.DataBind()
con.Close()
End Using
End Sub
End Class
HTMLコード
<asp:DropDownList ID = "DropDownList1" runat="server" onfocus="LoadStudent()" CssClass ="form-control">
</asp:DropDownList>
ブラザーのドロップダウンリストには、選択ごとに取り込まれます生徒クラスなので、onfocusやonblurで書かなければなりません。私はページロードイベントでそれを書くことができません。 –
DropDownListを更新する特定の学生の選択が変更されたときにイベントを設定できますか?あなたの学生が別のリストにあると仮定して、変更された時を決定するイベントを設定し、 'LoadStudent()'メソッドを呼び出します。 –