A
A P
Whats wrong with my code?
<%@ Page Language="VB" %>
<script runat="server">
' Insert page code here
'
Function GetDetails() As System.Data.DataSet
Dim connectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\DBs\"&
_
"\db.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT [tblmain].[DID],
[tblmain].[DDField], [tblmain].[SNo], [t"& _
"blmain].[DateFound] FROM [tbloprtrmain] WHERE ([tb"& _
"lmain].[Cancel] <> ""1"")"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Sub Page_Load(Sender As Object, E As EventArgs)
If Not Page.IsPostBack Then
DropDownList2.DataTextField = "DDField"
DropDownList2.DataSource = GetDetails()
DropDownList2.DataBind()
End If
End Sub
Sub DropDownList2_SelectedIndexChanged(sender As Object, e As EventArgs)
DataList1.DataSource =
GetDPRDetails(DropDownList2.Items(DropDownList2.SelectedIndex).Text)
DataList1.DataBind()
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
<font face="Arial"><strong>Show Details</strong></font>
</p>
<p>
<table>
<tbody>
<tr>
<td>
<p>
</p>
</td>
<td>
<aspropDownList id="DropDownList2"
runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"></aspropDownLi
st>
</td>
</tr>
</tbody>
</table>
</p>
<!-- Insert content here -->
<p>
<aspataList id="DataList1" runat="server">
<ItemTemplate>
Date Found: <asp:Label id="Label1" runat="server"
text='<%# DataBinder.Eval(Container.DataItem, "DateFound") %>'></asp:Label>
</ItemTemplate>
</aspataList>
</p>
</form>
</body>
</html>
it has an error:
Server Error in '/' Application.
----------------------------------------------------------------------------
----
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
Compiler Error Message: BC30367: Class 'System.Data.DataSet' cannot be
indexed because it has no default property.
Source Error:
Line 37:
Line 38: Sub DropDownList2_SelectedIndexChanged(sender As Object, e As
EventArgs)
Line 39: DataList1.DataSource =
GetDetails(DropDownList2.Items(DropDownList2.SelectedIndex).Text)
Line 40: DataList1.DataBind()
Line 41: End Sub
I've tried disabling the dropdownlist2_selectedIndexChanged and the dropdown
values worked, only when binding on datalist.
Pleae help.
Me
<%@ Page Language="VB" %>
<script runat="server">
' Insert page code here
'
Function GetDetails() As System.Data.DataSet
Dim connectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\DBs\"&
_
"\db.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT [tblmain].[DID],
[tblmain].[DDField], [tblmain].[SNo], [t"& _
"blmain].[DateFound] FROM [tbloprtrmain] WHERE ([tb"& _
"lmain].[Cancel] <> ""1"")"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Sub Page_Load(Sender As Object, E As EventArgs)
If Not Page.IsPostBack Then
DropDownList2.DataTextField = "DDField"
DropDownList2.DataSource = GetDetails()
DropDownList2.DataBind()
End If
End Sub
Sub DropDownList2_SelectedIndexChanged(sender As Object, e As EventArgs)
DataList1.DataSource =
GetDPRDetails(DropDownList2.Items(DropDownList2.SelectedIndex).Text)
DataList1.DataBind()
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
<font face="Arial"><strong>Show Details</strong></font>
</p>
<p>
<table>
<tbody>
<tr>
<td>
<p>
</p>
</td>
<td>
<aspropDownList id="DropDownList2"
runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"></aspropDownLi
st>
</td>
</tr>
</tbody>
</table>
</p>
<!-- Insert content here -->
<p>
<aspataList id="DataList1" runat="server">
<ItemTemplate>
Date Found: <asp:Label id="Label1" runat="server"
text='<%# DataBinder.Eval(Container.DataItem, "DateFound") %>'></asp:Label>
</ItemTemplate>
</aspataList>
</p>
</form>
</body>
</html>
it has an error:
Server Error in '/' Application.
----------------------------------------------------------------------------
----
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
Compiler Error Message: BC30367: Class 'System.Data.DataSet' cannot be
indexed because it has no default property.
Source Error:
Line 37:
Line 38: Sub DropDownList2_SelectedIndexChanged(sender As Object, e As
EventArgs)
Line 39: DataList1.DataSource =
GetDetails(DropDownList2.Items(DropDownList2.SelectedIndex).Text)
Line 40: DataList1.DataBind()
Line 41: End Sub
I've tried disabling the dropdownlist2_selectedIndexChanged and the dropdown
values worked, only when binding on datalist.
Pleae help.
Me