Hi
IN My application i am using grid, and binging the grid with list, and in the i applying 2 events selected index changed and pageindex changing event when i am clicking on a footer page index it is working and when i am trying to click on the second time it causes the following error and if try to select a record by clicking on select button also it causes the same error
please check this error and post the comments or mistakes in it
if you want the code
<asp:Content ID="Content3" ContentPlaceHolderID="cphContent" runat="server">
<asp:GridView ID="gvInvoiceslist" AutoGenerateColumns="false"
runat="server" OnSelectedIndexChanged="ViewInvoiceByRefId"
AllowPaging="true" onpageindexchanging="gvInvoiceslist_PageIndexChanging">
<Columns>
<asp:CommandField ButtonType="Image" EditText="View" ShowEditButton="true"/>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField id="hdnrefid" Value='<%#Eval("InvoiceRefID") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="ClientName" DataField="ClientName" />
<asp:BoundField HeaderText="InvoiceNumber" DataField="InvoiceNumber" />
<asp:BoundField HeaderText="Preparername" DataField="Preparername" />
<asp:BoundField HeaderText="TotalFees" DataField="TotalFees" />
<asp:BoundField HeaderText="TotalAmount" DataField="TotalAmount" />
</Columns>
</asp:GridView>
</asp:Content>
.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LOSIMSystem.BLL.Controllers;
namespace LOSIMSystem.Admin
{
public partial class InvoiceArchieved : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
BindInvoicesToGrid();
}
private void BindInvoicesToGrid()
{
InvoiceController invctrl = new InvoiceController();
gvInvoiceslist.DataSource = invctrl.GetAllInvoices();
gvInvoiceslist.DataBind();
}
protected void ViewInvoiceByRefId(object sender, EventArgs e)
{
int srowindex = gvInvoiceslist.SelectedIndex;
int refid =Convert.ToInt16(((HiddenField)gvInvoiceslist.Rows[srowindex].FindControl("hdnrefid")).Value);
InvoiceController invoicectrl = new InvoiceController();
Common.BussinessObjects.BLInvoice blinvoice= invoicectrl.GetInvoice(refid);
Response.Redirect("viewinvoice.aspx?hiddenid=" + refid);
}
protected void gvInvoiceslist_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvInvoiceslist.PageIndex = e.NewPageIndex;
}
}
}