gridview 按下一頁後,整個消失了
gridview 按下一頁後,整個消失了,以下是我的代碼.
protected void btnQuery_Click(object sender, EventArgs e)
{
Search();
}
//search data
protected void Search()
{
sqldsDiverLicense.ConnectionString = ConfigurationManager.ConnectionStrings["MovinavConnectionString"].ConnectionString;
gviewDiverLicense.DataSourceID = sqldsDiverLicense.ID;
string strSQL = "SELECT D.License_no, Right(D.License_no,4)+'/'+Left(D.License_no,4) as PLicense_no ,";
strSQL = strSQL + " dbo.b5_to_uc(P.cname) as cname,";
strSQL = strSQL + " POwner = dbo.b5_to_uc(CASE WHEN NOT D.Owner IS NULL THEN D.Owner ELSE A.Agency_cname END),";
strSQL = strSQL + " dbo.b5_to_uc(D.Subject) as Subject, dbo.b5_to_uc(D.Active_place) as Active_place,";
strSQL = strSQL + " D.Valid_date1, D.Valid_date2, D.Issue_date, D.Status,";
strSQL = strSQL + " dbo.b5_to_uc(S.Ship_cname) as ship_cname, S.Ship_pname";
strSQL = strSQL + " FROM DivrLicense D LEFT OUTER JOIN";
strSQL = strSQL + " Project P ON D.Project_no = P.Project_no LEFT OUTER JOIN";
strSQL = strSQL + " Agency A ON D.Agency_no = A.Agency_no LEFT OUTER JOIN";
strSQL = strSQL + " Ship S ON D.Ship_no = S.Ship_no";
strSQL = strSQL + " WHERE ((D.Status = 1) OR (D.Status = 2)) AND (D.Cancel = 0)";
if (txtValidDate.Text != "")
{
strSQL = strSQL + " AND (D.Valid_date2 >= '" + txtValidDate.Text + "')";
}
else
{
strSQL = strSQL + " AND (D.Valid_date2 < '1900/1/1')";
}
switch (cbQueryType.SelectedIndex) {
case 0 :
//...
break;
case 1 :
strSQL = strSQL + " AND (dbo.b5_to_uc(D.Owner) like N'%" + txtContent.Text + "%'";
strSQL = strSQL + " or dbo.b5_to_uc(A.Agency_cname) like N'%" + txtContent.Text + "%')";
break;
case 2 :
strSQL = strSQL + " AND (dbo.b5_to_uc(D.Subject) like N'%" + txtContent.Text + "%')";
break;
case 3:
strSQL = strSQL + " AND (dbo.b5_to_uc(S.Ship_cname) like N'%" + txtContent.Text + "%')";
break;
case 4:
strSQL = strSQL + " AND (S.Ship_pname like '%" + txtContent.Text + "%')";
break;
case 5:
strSQL = strSQL + " AND (D.Full_code like '%" + txtContent.Text + "%')";
break;
case 6:
strSQL = strSQL + " AND (dbo.b5_to_uc(P.Cname) like N'%" + txtContent.Text + "%')";
break;
case 7:
strSQL = strSQL + " AND (dbo.b5_to_uc(D.Active_place) like N'%" + txtContent.Text + "%')";
break;
case 8:
strSQL = strSQL + " AND (dbo.b5_to_uc(D.Description) like N'%" + txtContent.Text + "%')";
break;
default:
//...
break;
}
strSQL = strSQL + " ORDER BY D.License_no";
//Re