i trying implement gridview
manual paging. want add query string param
paging. seo
, absolutely required
. code published on website , has 500 entries(posts in gridview
).
now company wants me querystring param search engine can go through pages , captures it. right search engines seeing page 1 on gridview. thats came know seo team.
i dont have idea on how this. please help. can not change code because mess pages live.
girdview code
<asp:gridview runat="server" allowpaging="true" id="entriesgridview" autogeneratecolumns="false" datakeynames="entryid" showheader="false" onrowdatabound="entriesgridview_rowdatabound" cssclass="grid" onpageindexchanging="entriesgridview_pageindexchanging" pagesize="20"> <pagerstyle cssclass="pager"></pagerstyle> <columns> // template / bound fields </columns> <emptydatatemplate> // empty results text.... </emptydatatemplate> <emptydatarowstyle horizontalalign="center" /> </asp:gridview>
code-behind
protected void entriesgridview_pageindexchanging(object sender, gridviewpageeventargs e) { loadentriesgridview(false, false, false, sqlcriteria); entriesgridview.pageindex = e.newpageindex; entriesgridview.databind(); }
datasource
public static entrycollection loadforcriteriawithjoin(string sqlcriteria, bool isemailquery, bool isfullnamequery, string sortexpression) { //default sort expression if (string.isnullorempty(sortexpression)) sortexpression = "orderby"; //create dynamic sql load object var selectquery = new stringbuilder(); selectquery.append("select"); selectquery.append(" ce.* "); selectquery.append("from entrytable ce "); selectquery.append("join contestantstable cc "); selectquery.append("on ce.contestantid = cc.contestantid "); string whereclause = null; if (isemailquery) whereclause = "where ce.isapproved = 1 , cc.email = @emailaddress"; else if (isfullnamequery) whereclause = "where ce.isapproved = 1 , cc.firstname + ' ' + cc.lastname '%' + @fullname + '%'" + "or ce.cname '%' + @fullname + '%'" + "or ce.ctitle '%' + @fullname + '%'" + "or ce.answer1 + ' ' + ce.answer2 + ' ' + answer3 '%' + @fullname + '%'"; else whereclause = "where ce.isapproved = 2"; // returning empty result... if (!string.isnullorempty(sqlcriteria)) selectquery.append(whereclause); selectquery.append(" order " + sortexpression); var database = t.i.database; var selectcommand = database.getsqlstringcommand(selectquery.tostring()); if (isemailquery) database.addinparameter(selectcommand, "@email", system.data.dbtype.string, sqlcriteria); if (isfullnamequery) database.addinparameter(selectcommand, "@fullname", system.data.dbtype.string, sqlcriteria); //execute command var results = new entrycollection(); using (var dr = database.executereader(selectcommand)) { while (dr.read()) { var entry = new entry(); mwcompetitionsentry.loaddatareader(entry, dr); results.add(entry); } dr.close(); } return results; }
Comments
Post a Comment