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.CloseConnecti on)
'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 1 1393
I ahve fixed it the problem i was having is i fifnt have
If Not IsPostBack = True Then
on the page laod :$
Dessip wrote:
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.CloseConnecti on)
'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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Douglas Buchanan |
last post by:
I cannot access certain column values of a list box using code.
I have a list box 'lstPrv' populated by the query below.
SELECT tblPrv.fkPrvID, lkpCat.CatNm, lkpSrv.SrvNm, lkpCat.pkCatID,...
|
by: Simon P |
last post by:
Hello group, I'm in desperate need of help. Here goes :
I have the following tables : CONTACTS (ContactID, FirstName,
LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and
SHOWDETAILS...
|
by: Rob |
last post by:
I have a listbox which is populated by a dataset:
'initiate the DataSet and all the rest here
my sql statement is this:
SELECT company_id, name, description FROM companies
ds =...
|
by: Janaka |
last post by:
Help! I have two ListBox controls on my web form. The first one gets
populated on entry with values from the DB. I then use JavaScript to copy
options from this ListBox to my second one. (I...
|
by: amber |
last post by:
Hello
I'm not sure if I should give up trying to find an answer here...or just keep posting my problem..
I'm having problems with a listbox..
I have a listbox that is populated when a user...
|
by: |
last post by:
Greets All,
Question on data in datagrid /listbox and looping?
I’m trying to decide the best way to write this code.
1 would like the user to make several selections from one listbox/combo box...
|
by: Dave |
last post by:
Hi All,
I have a windows form that contains 2 listboxes and 2 buttons.
The listbox on the right is populated by a database routine (This is the
easy part).
The listbox on the left is populated...
|
by: John |
last post by:
I have a listbox that is databound when my form loads. A user
can then select and option using a drop down box. When the user
selects an option the corresponding items in the listbox gets selected....
|
by: ahilar12 |
last post by:
1. <head>
2. <script type="text/javascript">
3. </script>
4. </head>
5. <body>
6. <form>
7. <select name="team" id="mylist" >
8. <option></option>
9....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |