I originally had database issues with my GridView table to database but I have corrected it.
My major issue I have faced is the fact that regardless of whether I use my <td> Classified Ads </td>
link or a button, when I click it the code in Visual Studio still initiates regarless of the fact that it is all inside the code If Not IsPostBack Then
.
I think my issue is the fact that the page loads regardless when I click the link. I know this for fact because when I debug it and click on the link the Visual Studio code still runs.
How can I fix this issue?
Where link is (Text that says: Classified Ads):
<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
I guess how I fixed it (which not sure what this process would be called is) but I needed to fix my Response.Redirect for the button link version.
In other words, the properties of the button I did an edit to the PostBackUrl:
And for the VB code I added the "True" part: