【发布时间】:2023-03-30 01:49:02
【问题描述】:
我的 GridView 表到数据库最初存在数据库问题,但我已更正它。
我面临的主要问题是,无论我使用<td> Classified Ads </td> 链接还是按钮,当我单击它时,Visual Studio 中的代码仍然会启动,而不管它都在代码中@ 987654323@.
我认为我的问题是无论我何时单击链接都会加载页面。我知道这一点,因为当我调试它并单击链接时,Visual Studio 代码仍然运行。
我该如何解决这个问题?
链接在哪里(文字显示:分类广告):
<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
【问题讨论】:
-
不要使用 href = user onclick 属性并捕获事件
-
不知道你所说的“赶上活动”是什么意思
标签: asp.net visual-studio-2010 datasource