2011-01-19 2 views
0

내 asp.net webform에 gridview가 있습니다. 내가 2 페이지 누르면 allowPaging = trueallowPaging = true 일 때 gridview 오류 - asp.net

의 쇼 데이터를 그리드에,하지만 .. :

내가 이렇게 GRIDVIEW 내 데이터베이스에 바인딩 :

SQL = "SELECT id,Fname,Lname FROM MEN"; 
dsView = new DataSet(); 
adp = new SqlDataAdapter(SQL, Conn); 
adp.Fill(dsView, "MEN"); 
adp.Dispose(); 
GridView1.DataSource = dsView.Tables[0].DefaultView; 
GridView1.DataBind(); 

를이 내가이있는 gridview에 넣어 3 ..

그리고 난이 오류가있어 : 사전에

The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. 

감사

답변

4

PageIndexChanging 이벤트를 처리해야합니다. 디자이너에서 격자를 클릭하고 이벤트를 살펴본 후 PageIndexChanging 이벤트를 두 번 클릭하거나 취소하거나 특별한 작업을 할 필요가없는 경우 데이터를 리 바인드하면됩니다. GridView1_PageIndexChanging 이벤트에서이 같은 핸들러

+0

감사! 나는 그것을 시도하고 오류는 없지만, 다음 10 ... 20 .... 기록을 보여주는 방법? – Gali

+0

게시 한 코드는 데이터 바인딩을 수행합니다.이를 메소드에 넣고 이벤트에서 호출합니다. – kd7

+0

나는 이것을 시도한다 - 그러나 나는 같은 기록을 본다. 다음 10.20 .. 기록이 없다. – Gali

1

페이징 논리를 제공하는 PageIndexChanging에 대한 이벤트 처리기를 제공해야합니다.

0

쓰기에 :

GridView1.PageIndex = e.NewPageIndex; 

은 다시 그리드를 바인딩합니다. ur prob로 해결됩니다.

3

당신은 System.Collections.Generic를 사용하여 네임 스페이스

을 추가해야합니다;

public void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 
{ 
    GridView1.PageIndex = e.NewPageIndex; 
    BindGridview(); 
} 

그것은 100 % 작동 그것을 시도,이 코드를 작성 ......

관련 문제