On my pages I am using a <asp:label> to populate the page title. It works good, but when in my grid view a user clicks First - Previous - Next - Last, the label keeps adding the page title over and over
LABEL
<asp:Label ID="Label2" runat="server" Text="Question's Related To " CssClass="lblTitle"></asp:Label>
On page load as an example shows: Question's Related To All Questions
When paging direction is clicked:
First click returns: Question's Related To All Questions All Questions
Second click returns: Question's Related To All Questions All Questions All Questions
Each time it is clicked this happens. When the page is refreshed it stays the same. Only way to reset to the text the should display (Question's Related To All Questions) is to click the link that loads the page.
I was thinking that this might deal with using IsPostBack, but that is not working either.
What I have tried:
mainForum.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request.QueryString("cat") <> Nothing Then
ForumDataSource.FilterExpression = "Category='" & Request.QueryString("cat") & "'"
Label2.Text &= " " & Request.QueryString("cat")
Else
Label2.Text &= " All Questions"
End If
If Not IsPostBack Then
' Validate initially to force the asterisks
' to appear before the first roundtrip.
Validate()
End If
End Sub
mainForum.aspx
<asp:GridView ID="GridView1" runat="server" BorderWidth="0" Width="100%" AllowPaging="True" AllowSorting="True" PageIndex="4" PageSize="30" AutoGenerateColumns="False" DataKeyNames="QID" DataSourceID="ForumDataSource" EnableModelValidation="True">
<RowStyle BackColor="#dde8ed" />
<AlternatingRowStyle BackColor="#beced5" />
<PagerSettings PageButtonCount="4" Mode="NextPreviousFirstLast" Position="TopAndBottom" FirstPageText="First " PreviousPageText=" Previous " NextPageText=" Next " LastPageText=" End" />
<PagerStyle HorizontalAlign="Center" VerticalAlign="Middle" BackColor="#233f5e" Font-Underline="false" ForeColor="#c7d1e0" Font-Names="Arial" Font-Size="9pt" Font-Bold="true" Width="100%" Height="22px" />
<EmptyDataTemplate>
Now Questions were found
</EmptyDataTemplate>
<FooterStyle CssClass="gridbg" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="Category" DataNavigateUrlFormatString="mainForum.aspx?cat={0}" DataTextField="Category" HeaderText="Category" NavigateUrl="mainForum.aspx?cat=" SortExpression="Category" Text="Category" >
<HeaderStyle BackColor="#5B6776" Font-Names="Arial" Font-Size="9pt" ForeColor="#C7DEE9" HorizontalAlign="Center" VerticalAlign="Middle" Width="17%" />
<ItemStyle Font-Names="Arial" Font-Size="8pt" ForeColor="#022638" HorizontalAlign="Left" VerticalAlign="Middle" Width="17%" Height="20px" CssClass="ingrid" />
</asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="QID" DataNavigateUrlFormatString="AnswerList.aspx?qid={0}" DataTextField="Question" HeaderText="Question(s) Asked" NavigateUrl="AnswerList.aspx?qid=" SortExpression="Question" Text="Question" >
<HeaderStyle BackColor="#5B6776" Font-Names="Arial" Font-Size="9pt" ForeColor="#C7DEE9" HorizontalAlign="Center" VerticalAlign="Middle" Width="56%" />
<ItemStyle Font-Names="Arial" Font-Size="8pt" ForeColor="#022638" HorizontalAlign="Left" VerticalAlign="Middle" Width="56%" Height="20px" CssClass="ingrid" />
</asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="PostedBy" DataNavigateUrlFormatString="Profile.aspx?mem={0}" DataTextField="PostedBy" HeaderText="Posted By" NavigateUrl="Profile.aspx?mem=" SortExpression="PostedBy">
<HeaderStyle BackColor="#5B6776" Font-Names="Arial" Font-Size="9pt" ForeColor="#C7DEE9" HorizontalAlign="Center" VerticalAlign="Middle" Width="17%" />
<ItemStyle Font-Names="Arial" Font-Size="8pt" ForeColor="#022638" HorizontalAlign="Left" VerticalAlign="Middle" Width="15%" Height="20px" CssClass="ingrid" />
</asp:HyperLinkField>
<asp:BoundField DataField="PostedDate" HeaderText="Post Date" DataFormatString="{0}" SortExpression="PostedDate" >
<HeaderStyle BackColor="#5B6776" Font-Names="Arial" Font-Size="9pt" ForeColor="#C7DEE9" HorizontalAlign="Center" VerticalAlign="Middle" Width="12%" />
<ItemStyle Font-Names="Arial" Font-Size="8pt" ForeColor="#022638" HorizontalAlign="Center" VerticalAlign="Middle" Width="12%" Height="20px" />
</asp:BoundField>
</Columns>
</asp:GridView>