Click here to Skip to main content
15,904,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear sirs
i was trying the following

An ASP.NET DataGrid with AutoFilter[^]

the auto filter appears but never worked , whatever i choose any item to filter on it
i got ArgumentOutOfRangeException

i found that ArrayList list which used in the OnItemDataBound is became empty when the RaisePostBackEvent is called

System.ArgumentOutOfRangeException was unhandled by user code
Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source=mscorlib
ParamName=index
StackTrace:
at System.Collections.ArrayList.get_Item(Int32 index)
at DataGridAF.DataGridAutoFilter.RaisePostBackEvent(String eventArgument) in C:\Users\admin\Desktop\dwn\DataGridAF\DataGridAutoFilter.cs:line 143
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Posted

1 solution


It the easy way but something like this should work


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}

protected void UpdateFilter(object sender, EventArgs e)
{
BindGrid();
}

private void BindGrid()
{
DataTable dt = new DataTable();
//...
dt.DefaultView.RowFilter = "SomeColumnInTheDataTable = '" + SearchText.Text + "'";
gvProjList.DataSource = dt.DefaultView;
gvProjList.DataBind();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900