Я новичок в веб-строительстве.У меня есть следующий список на странице.На странице включено состояние просмотра.
<asp:ListBox ID="ExamsList_ListBox" runat="server" DataTextField="Namee" viewstate="enabled"
DataValueField="ID" AutoPostBack="true" Height="213px" Width="152px"
ViewStateMode="Enabled" />
Данные привязываются к данным во время выполнения.Я могу видеть список, но listbox.selectedindex всегда приводит к значению «-1», даже если я нажимаю 10-й в поле.подскажите, пожалуйста, что не так.
Вот код страницы:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body >
<form id="form1" runat="server">
<div>
<div>
<asp:ListBox ID="ExamsList_ListBox" runat="server" DataTextField="Namee" viewstate="enabled"
DataValueField="ID" AutoPostBack="true" Height="213px" Width="152px"
ViewStateMode="Enabled" />
</div>
</div>
</form>
</body>
</html>
и код для заполнения данных:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsNothing(CType(Session("Login"), TikoClasses.Login)) Then
Response.Redirect("~/default.aspx")
ElseIf (CType(Session("Login"), TikoClasses.Login)).Admin = False Then
Response.Redirect("~/Loggedin/Welcome.aspx")
End If
ExamsList_ListBox.DataSource = DataModule.Exams_listall((CType(Session("Login"), TikoClasses.Login)).Inst_ID)
ExamsList_ListBox.DataBind()
End Sub
и выборизменилось даже:
Try
Dim k As Integer = ExamsList_ListBox.SelectedIndex
Dim tt As List(Of Integer) = ExamsList_ListBox.GetSelectedIndices.ToList
Dim t As Object = ExamsList_ListBox.SelectedValue
If ExamsList_ListBox.SelectedIndex > -1 Then
DataModule.GetExam(CType(Session("Login"), TikoClasses.Login).Inst_ID, ExamsList_ListBox.SelectedValue)
End If
Catch ex As Exception
End Try
Нужна помощь.Заранее спасибо.