but when I click on the title to sort or page it returns a blank page. I am using visual studio 2010 C#
here is my aspx code
Expand|Select|Wrap|Line Numbers
- <asp:GridView ID="GridView1" runat="server"
- AutoGenerateColumns="False" PageSize="20"
- AllowSorting="True" OnSorting="GridView1_Sorting"
- AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging"
- style="margin-left: 0px" width="400px" CellPadding="1
- " ForeColor="#333333"
- GridLines="None">
- <AlternatingRowStyle BackColor="White" />
- <Columns>
- <asp:hyperlinkfield headertext="ImageID"
- DataTextField="ImageID"
- DataNavigateUrlFields="ImageID"
- NavigateUrl ="C:\"
- DataNavigateUrlFormatString="./ImageID.jpg" />
- <asp:BoundField DataField="GivenName" HeaderText="GivenName"
- SortExpression="GivenName" />
- <asp:BoundField DataField="Surname" HeaderText="Surname"
- SortExpression="Surname" />
- <asp:BoundField DataField="DeathYear" HeaderText="DeathYear"
- SortExpression="DeathYear" />
- <asp:BoundField DataField="BirthYear" HeaderText="BirthYear"
- SortExpression="BirthYear" />
- <asp:BoundField DataField="FatherGivenNm" HeaderText="FatherGivenNm"
- SortExpression="FatherGivenNm" />
- <asp:BoundField DataField="FatherSurname" HeaderText="FatherSurname"
- SortExpression="FatherSurname" />
- <asp:BoundField DataField="MotherSurname" HeaderText="MotherSurname"
- SortExpression="MotherSurname" />
- <asp:BoundField DataField="MotherGivenNm" HeaderText="MotherGivenNm"
- SortExpression="MotherGivenNm" />
- <asp:BoundField DataField="SpouseGivenNm" HeaderText="SpouseGivenNm"
- SortExpression="SpouseGivenNm" />
- <asp:BoundField DataField="SpouseSurname" HeaderText="SpouseSurname"
- SortExpression="SpouseSurname" />
- </Columns>
- <EditRowStyle BackColor="#2461BF" />
- <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
- <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
- <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
- <RowStyle BackColor="#EFF3FB" />
- <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
- <SortedAscendingCellStyle BackColor="#F5F7FB" />
- <SortedAscendingHeaderStyle BackColor="#6D95E1" />
- <SortedDescendingCellStyle BackColor="#E9EBEF" />
- <SortedDescendingHeaderStyle BackColor="#4870BE" />
- </asp:GridView>
- my code behind
- public void bindGridView(string sortExp, string sortDir)
- {
- if (GridView1.Rows.Count >0 )
- {
- System.Web.HttpContext context = System.Web.HttpContext.Current;
- fname = context.Session["fname"].ToString();
- lname = context.Session["lname"].ToString();
- birthMonth = context.Session["birthMonth"].ToString();
- birthDay = context.Session["birthDay"].ToString();
- birthYear = context.Session["birthYear"].ToString();
- deathMonth = context.Session["deathMonth"].ToString();
- deathDay = context.Session["deathDay"].ToString();
- deathYear = context.Session["deathYear"].ToString();
- fatherFname = context.Session["fatherFname"].ToString();
- fatherLname = context.Session["fatherLname"].ToString();
- motherFname = context.Session["motherFname"].ToString();
- motherLname = context.Session["motherLname"].ToString();
- spouseFname = context.Session["spouseFname"].ToString();
- spouseLname = context.Session["spouseLname"].ToString();
- ViewState["SortExpression"] = sortExp;
- dataTableResult = archiveAccess.GetDeathInfo(fname, lname, birthYear, deathYear, fatherFname, fatherLname, motherFname, motherFname, spouseFname, spouseLname);
- DataView myDataView = new DataView(dataTableResult);
- if ((GridView1 != null))
- {
- myDataView.Sort = string.Format("{0} {1}", sortExp, sortDir);
- }
- GridView1.DataSource = myDataView;
- GridView1.AllowSorting = true;
- GridView1.AllowPaging = true;
- GridView1.DataBind();
- }
- }
- protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
- {
- bindGridView(e.SortExpression, sortOrder);
- }