DataSource error: UllReferenceExeption was unhandled by user code
DataSource error: UllReferenceExeption was unhandled by user code
我的 GridView table 数据库最初存在数据库问题,但我已更正它。
我面临的主要问题是,无论我使用 <td> Classified Ads </td>
link 还是按钮,当我单击它时 Visual Studio 中的代码仍然会启动事实上,它都在代码 If Not IsPostBack Then
.
中
我认为我的问题是无论我何时单击 link,页面都会加载。我确实知道这一点,因为当我调试它并单击 link 时,Visual Studio 代码仍然运行。
我该如何解决这个问题?
其中 link 是(上面写着:分类广告的文字):
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="middle" width="87%">
<a href="Index.aspx" style="text-decoration:none;" ><font color="000000"
face="Verdana, Arial, Helvetica, sans-serif" size="2.7"><b>Classified Ads</b></font>
</a>
<font color="000000" face="Verdana, Arial, Helvetica, sans-serif" size="2.7" style="padding-top:5px">></font>
<a style="text-decoration:none;" href="WF_DisplayAll.aspx">
<font color="000000" face="Verdana, Arial, Helvetica, sans-serif" size="2.7"><b>All Classified Ads</b></font>
</a>
</td>
<td width="13%" valign="middle" align="right">
<a style="text-decoration:none;" href="Login.aspx">
<font color="000000" face="Verdana, Arial, Helvetica, sans-serif" size="2.7"> Admin  </font></a>
</td>
</tr>
</table>
Visual Studio:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'OleDbDataAdapterSecurity.SelectCommand.CommandText = "SELECT Addate, username, Phonenbr, email, description FROM t_classifieds"
'Dim OracleDataAdapterAds As OracleDataAdapter = New OracleDataAdapter
'OracleDataAdapterAds.SelectCommand = strSelectAds
' Makes so it runs the first time
If Not IsPostBack Then
Dim conn As OleDbConnection = New OleDbConnection("Provider=""******"";user id=" & strUserID & ";data source=" & strDatabase & ";password=" & strPssWd)
'Display All Classified Ads listed in the Database based on the following format/order
'Date Name Home Phone Number Description
Dim ClassifiedStr As OleDbCommand = New OleDbCommand("SELECT classid, Addate, username, Phonenbr, email, description FROM t_classifieds", conn)
Dim OracleDataAdapterAds As OleDbDataAdapter = New OleDbDataAdapter
OracleDataAdapterAds.SelectCommand = ClassifiedStr
Dim DsAds As DataSet = New DataSet
DsAds.Clear()
OracleDataAdapterAds.Fill(DsAds, "t_classifieds")
DisplayAllClassifieds.DataSource = DsAds
DisplayAllClassifieds.DataMember = "t_classifieds"
DisplayAllClassifieds.DataBind()
End If
End Sub
我想我是如何修复它的(不确定这个过程会被称为什么)但我需要修复我的 Response.Redirect 按钮 link 版本。
换句话说,按钮的属性我对 PostBackUrl 进行了编辑:
对于 VB 代码,我添加了 "True" 部分:
Protected Sub Main_Click(sender As Object, e As EventArgs) Handles Main.Click
Response.Redirect("Index.aspx", True)
End Sub
我的 GridView table 数据库最初存在数据库问题,但我已更正它。
我面临的主要问题是,无论我使用 <td> Classified Ads </td>
link 还是按钮,当我单击它时 Visual Studio 中的代码仍然会启动事实上,它都在代码 If Not IsPostBack Then
.
我认为我的问题是无论我何时单击 link,页面都会加载。我确实知道这一点,因为当我调试它并单击 link 时,Visual Studio 代码仍然运行。
我该如何解决这个问题?
其中 link 是(上面写着:分类广告的文字):
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="middle" width="87%">
<a href="Index.aspx" style="text-decoration:none;" ><font color="000000"
face="Verdana, Arial, Helvetica, sans-serif" size="2.7"><b>Classified Ads</b></font>
</a>
<font color="000000" face="Verdana, Arial, Helvetica, sans-serif" size="2.7" style="padding-top:5px">></font>
<a style="text-decoration:none;" href="WF_DisplayAll.aspx">
<font color="000000" face="Verdana, Arial, Helvetica, sans-serif" size="2.7"><b>All Classified Ads</b></font>
</a>
</td>
<td width="13%" valign="middle" align="right">
<a style="text-decoration:none;" href="Login.aspx">
<font color="000000" face="Verdana, Arial, Helvetica, sans-serif" size="2.7"> Admin  </font></a>
</td>
</tr>
</table>
Visual Studio:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'OleDbDataAdapterSecurity.SelectCommand.CommandText = "SELECT Addate, username, Phonenbr, email, description FROM t_classifieds"
'Dim OracleDataAdapterAds As OracleDataAdapter = New OracleDataAdapter
'OracleDataAdapterAds.SelectCommand = strSelectAds
' Makes so it runs the first time
If Not IsPostBack Then
Dim conn As OleDbConnection = New OleDbConnection("Provider=""******"";user id=" & strUserID & ";data source=" & strDatabase & ";password=" & strPssWd)
'Display All Classified Ads listed in the Database based on the following format/order
'Date Name Home Phone Number Description
Dim ClassifiedStr As OleDbCommand = New OleDbCommand("SELECT classid, Addate, username, Phonenbr, email, description FROM t_classifieds", conn)
Dim OracleDataAdapterAds As OleDbDataAdapter = New OleDbDataAdapter
OracleDataAdapterAds.SelectCommand = ClassifiedStr
Dim DsAds As DataSet = New DataSet
DsAds.Clear()
OracleDataAdapterAds.Fill(DsAds, "t_classifieds")
DisplayAllClassifieds.DataSource = DsAds
DisplayAllClassifieds.DataMember = "t_classifieds"
DisplayAllClassifieds.DataBind()
End If
End Sub
我想我是如何修复它的(不确定这个过程会被称为什么)但我需要修复我的 Response.Redirect 按钮 link 版本。
换句话说,按钮的属性我对 PostBackUrl 进行了编辑:
对于 VB 代码,我添加了 "True" 部分:
Protected Sub Main_Click(sender As Object, e As EventArgs) Handles Main.Click
Response.Redirect("Index.aspx", True)
End Sub