0

I want to fill a drop down list with some data in a data source.
I defined a page level array and redim it in Page_Load.
I get an error saying
"Object reference not set to an instance of an object"
The error occurs at the statement,
Page.DataBind()
Below is the code (I omitted unnesary HTML codes
for the presentation)
Can you please tell me how to correct this?
Thank you
vbgaya.
===============
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
dim strService(5) as string
sub Page_Load(obj as object, e as EventArgs)
dim objConn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/scms/database/scms.mdb"))
objConn.Open()
dim objCmd as new OleDbDataAdapter("select * from services", objConn)
Dim cb as New OleDbCommandBuilder(objCmd)
dim ds as DataSet = new DataSet()
objCmd.Fill(ds, "services")
dim n as integer
n = ds.Tables("services").Rows.Count
redim strService(n)
dim i as integer
for i = 0 to n-1
strService(i) = ds.Tables("services").Rows(i)("ServceName").ToString
next
objConn.Close()
Page.DataBind()
end sub
</script>
<html>
<head>
<title>Maintain Categories</title>
<link rel="stylesheet" type="text/css" href="support-files/main.css">
</head>
<body>
<form runat="server">
<asp:dropdownlist ID="lbService" DataSource='<%# strService %>' runat="server" />
</form>
</body>
</html>

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by postmaster
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.