D
Dessip
Hey there,
my question is, I have got 2 List Boxes, on a page, and listbox 1
generates list box 2 items, but both are generated from SQL, but its
not worknig on auto post back:
Code
================================================
Private Sub LsbImporting_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox2.SelectedIndexChanged
Dim x
For x = 0 To ListBox2.Items.Count - 1
If ListBox2.Items(x).Selected Then Label1.Text += "1"
Next
End Sub
=================================================
That is getting called all the time, but the selected value always =
False, even if i have selected some items
here is the HTML for the list box:
================================================
div>
<asp:listbox id="lsbImporting" CssClass="lblMain"
Runat="server" AutoPostBack="True">Importing From:</asp:listbox>
<asp:listbox id="lsbImportRegion" CssClass="lsbMain"
Runat="server" SelectionMode="Multiple"></asp:listbox>
</div>
================================================
Here is the SQL im useing to import the data:
================================================
Public Function ReturnSQLDataReader(ByVal SQLConnString As String,
ByVal sSQLCmd As String) As SqlClient.SqlDataReader
Dim oSQLConn As SqlConnection = New SqlConnection
oSQLConn.ConnectionString = SQLConnString
oSQLConn.Open()
Dim SQLCmd As SqlClient.SqlCommand = New
SqlClient.SqlCommand(sSQLCmd, oSQLConn)
'Dim SQLReader As SqlClient.SqlDataReader
Return SQLCmd.ExecuteReader(CommandBehavior.CloseConnection)
'SQLReader = Nothing
oSQLConn.Close()
oSQLConn = Nothing
End Function
-----------------------------------------------------------
Dim SQLFun As New SQLFunctions
lsbImporting.DataSource = SQLFun.ReturnSQLDataReader("Data
Source=127.0.0.1\SQLEXPRESS;Initial Catalog=ProduceTracker;Integrated
Security=SSPI;Packet Size=4096;", "SELECT DISTINCT year FROM
CropImportExport ORDER BY Year DESC")
lsbYear.DataTextField = "Year"
lsbYear.DataBind()
================================================
Any help would be excelent, i have no idea why they are not showing i
was guessing it was because of the SQL, but im not sure.
Thanks in advance
Chris
my question is, I have got 2 List Boxes, on a page, and listbox 1
generates list box 2 items, but both are generated from SQL, but its
not worknig on auto post back:
Code
================================================
Private Sub LsbImporting_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox2.SelectedIndexChanged
Dim x
For x = 0 To ListBox2.Items.Count - 1
If ListBox2.Items(x).Selected Then Label1.Text += "1"
Next
End Sub
=================================================
That is getting called all the time, but the selected value always =
False, even if i have selected some items
here is the HTML for the list box:
================================================
div>
<asp:listbox id="lsbImporting" CssClass="lblMain"
Runat="server" AutoPostBack="True">Importing From:</asp:listbox>
<asp:listbox id="lsbImportRegion" CssClass="lsbMain"
Runat="server" SelectionMode="Multiple"></asp:listbox>
</div>
================================================
Here is the SQL im useing to import the data:
================================================
Public Function ReturnSQLDataReader(ByVal SQLConnString As String,
ByVal sSQLCmd As String) As SqlClient.SqlDataReader
Dim oSQLConn As SqlConnection = New SqlConnection
oSQLConn.ConnectionString = SQLConnString
oSQLConn.Open()
Dim SQLCmd As SqlClient.SqlCommand = New
SqlClient.SqlCommand(sSQLCmd, oSQLConn)
'Dim SQLReader As SqlClient.SqlDataReader
Return SQLCmd.ExecuteReader(CommandBehavior.CloseConnection)
'SQLReader = Nothing
oSQLConn.Close()
oSQLConn = Nothing
End Function
-----------------------------------------------------------
Dim SQLFun As New SQLFunctions
lsbImporting.DataSource = SQLFun.ReturnSQLDataReader("Data
Source=127.0.0.1\SQLEXPRESS;Initial Catalog=ProduceTracker;Integrated
Security=SSPI;Packet Size=4096;", "SELECT DISTINCT year FROM
CropImportExport ORDER BY Year DESC")
lsbYear.DataTextField = "Year"
lsbYear.DataBind()
================================================
Any help would be excelent, i have no idea why they are not showing i
was guessing it was because of the SQL, but im not sure.
Thanks in advance
Chris