내 GridView에서 페이징을 수행하고 이전에 멋지게 작동했습니다. TextBox의 "사용자 키"값으로 필터링했습니다. 그러나, 필자는 GridView에 필터링을 추가했기 때문에 페이징에는 몇 가지 문제가있다. 사용자가 2 페이지를 클릭하면 필터링되기 전에 GridView 페이지 2가 표시됩니다.필터링 후 Gridview 페이징
나를 도와 줄 사람이 있습니까?
protected void gvPaging(object sender, GridViewPageEventArgs e)
{
DefaultData();
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
필터링 코드 :
protected void Button1_Command(object sender, EventArgs e)
{
string folderName = ConfigurationManager.AppSettings["folderPDF"].ToString();
string path = Server.MapPath("./");
string fpaths = path + folderName;
string[] filePath = Directory.GetFiles(fpaths, "*.pdf");
DataTable table = GetTable(filePath);
//var dataTable = (DataTable)GridView1.DataSource;
var dataView = table.DefaultView;
dataView.RowFilter = "folderName LIKE '" + DocSearch.Text.Trim() + "%'";
GridView1.DataSource = table;
GridView1.DataBind();
DocSearch.Text = "";
}
DefaultData()
public void DefaultData()
{
string folderName = ConfigurationManager.AppSettings["folderPDF"].ToString();
string path = Server.MapPath("./");
string fullPath = path + folderName;
string[] filePaths = Directory.GetFiles(fullPath, "*.pdf");
DataTable table = GetTable(filePaths);
GridView1.DataSource = table;
GridView1.DataBind();
}
GridView를 필터링하는 방법을 보여줍니다. 'DefaultData'에 같은 필터를 적용해야합니다. GridView 자체가 아닌 항상 데이터 소스를 필터링해야합니다. –