2016-12-13 23 views
0

有人可以向我解釋爲什麼我的EmployeeSearchResultsList_DataBindingComplete沒有發射?這是我的理解,RowDataBound完成綁定數據後,它會自動啓動DataBindingCompleteASP.NET窗體 - DataBindingComplete沒有發射

的GridView:

<asp:GridView ID="employeeSearchResultsList" runat="server" CssClass="GridView" AutoGenerateColumns="false" ShowHeaderWhenEmpty="true" OnSelectedIndexChanged="EmployeeSearchResultsList_SelectedIndexChanged" OnRowDataBound="EmployeeSearchResultsList_RowDataBound" OnDataBindingComplete="EmployeeSearchResultsList_DataBindingComplete"> 
    <Columns> 
     <asp:ButtonField HeaderText="Select" CommandName="select" Text="Select" ItemStyle-Width="50px" /> 
     <asp:BoundField HeaderText="ID" DataField="ID" ItemStyle-Width="50px" /> 
     <asp:BoundField HeaderText="Last Name" DataField="lastName" ItemStyle-Width="150px" /> 
     <asp:BoundField HeaderText="First Name" DataField="firstName" ItemStyle-Width="150px" /> 
     <asp:BoundField HeaderText="Middle Name" DataField="middleName" ItemStyle-Width="100px" /> 
     <asp:BoundField HeaderText="Status" DataField="status" ItemStyle-Width="100px" /> 
    </Columns> 
</asp:GridView> 

的RowDataBound:

protected void EmployeeSearchResultsList_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    // Magic 
} 

DataBindingComplete:

protected void EmployeeSearchResultsList_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) 
{ 
    // It does not hit here 
} 
+0

你真的在DGV上調用'bind()'嗎? – TheValyreanGroup

+0

我是。被忽略發佈。它在此之前發生。基本上得到一個員工名單,並綁定到gridview。 –

回答

1

GridView中沒有一個DataBindingComplete事件。只有Webform的DataGridView控件有這個功能。

從你的問題,目前還不清楚你想要處理的事件。也許我們可以提供替代方案。

+0

因此,ASP.NET Forms中無法檢測DataBind()何時完成? –

+1

不是我所知道的。查看所有事件[這裏](https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview_events(v = vs.110).aspx) – VDWWD

+0

基本上,我需要設置一個GridIndex中定義的項目的tabIndex。當數據綁定完成時,我的想法就是抓住這一點。 –