ListBox problem

Joined
Nov 17, 2008
Messages
2
Reaction score
0
Hi All,
I am getting "Object reference not set to an instance of an object" although I am using "If Not IsPostBack Then .. END IF" while populating the data in the list-box.
Weird thing is that I have been using other Liston having same properties and functionality and they are working fine.

Have u been through this problem before? Any Suggestions?
Here is the code:

IN .aspx
<asp:ListBox ID="lstBox2" runat="server" AutoPostBack="True" DataMember="DefaultView"
Rows="10" Visible="False" Width="296px" style="clear: both; display: inline; Left: 640px; position: absolute;
top: 261px; visibility: visible; overflow: auto; list-style-type: decimal; list-style-position: inside; float: right;" Height="65px" ></asp:ListBox>

In .vb

If Not IsPostBack Then
strlst = "Select UID, BDate, EDate from MyTable where App= 'Yes' "
adptrlst = New SqlDataAdapter(strlst, MyConn)
MyConn.Open()
dslst = New DataSet
adptrlst.Fill(dslst, "Mytable")
dtlst = dslst.Tables("Mytable")
lstBox2.DataSource = dtlst
If (dtlst.Rows.Count < 1) Then
lblStatus.Visible = True
lblStatus.Text = "No Requests"
Else
For i = 0 To dtlst.Rows.Count - 1
Me.Label1.Visible = True
lstBox2.Visible = "True"
bdate = getDateOnly(dtlst.Rows(i).Item(1))
edate = getDateOnly(dtlst.Rows(i).Item(2))

lstBox2.Items.Add(dtlst.Rows(i).Item(0) & "," & bdate & "," & edate)

Next
End If
End If

Thank you very much in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top