我最初将GridView表的数据库问题发送到数据库,但我已经纠正了它。
我遇到的主要问题是,无论我使用<td> Classified Ads </td>
链接还是按钮,当我点击它时,Visual Studio中的代码仍会启动,而不管它是否都在代码If Not IsPostBack Then
。
我认为我的问题是,无论何时点击链接,页面都会加载。我知道这是事实,因为当我调试它并单击链接时,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
答案 0 :(得分:0)
我想我是如何修复它的(不知道这个进程会被调用的是什么)但是我需要修复我的Response.Redirect按钮链接版本。
换句话说,按钮的属性我对PostBackUrl进行了编辑:
对于VB代码,我添加了“True”部分:
Protected Sub Main_Click(sender As Object, e As EventArgs) Handles Main.Click
Response.Redirect("Index.aspx", True)
End Sub