2014-01-30 17 views
0

我想初始化DataPagerSetPageProperties()方法,但由於未知原因,我得到這個DataPager1沒有找到一個ListView

錯誤「Appointement」不包含「DataPager1」的定義,並沒有擴展方法「 DataPager1' 接受型的第一參數‘Appointement’可以找到(是否缺少using指令或程序集引用?)

下面是代碼

protected void ListView1_PagePropertiesChanged(object sender, EventArgs e) 
{ 
    indexDdl = Convert.ToInt32(Session["dentistId"]); 

    int StartRowIndex = 0; 
    int MaximumRows = 10; 
    this.DataPager1.SetPageProperties(StartRowIndex, MaximumRows, true); <= error with DataPager1 
    Appointement(indexDdl); 
} 

這裏是.aspx頁面中

<asp:DataPager ID="DataPager1" runat="server" Autopostback="true" > 
    <Fields> 
     <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
      ShowLastPageButton="True" /> 
    </Fields> 
</asp:DataPager> 

爲什麼它不工作,你知道嗎?

+0

我不認爲'這個'可以在這裏使用。當您點擊'。'時,intellisense會看到DataPager1嗎?在這之後'? – 2014-01-30 02:17:27

+0

我沒有在代碼中看到'Appointement'。 –

回答

0
DataPager DataPager1; 
    DataPager DataPager1 = ListView1.FindControl("DataPager1") as DataPager;