-1
我有一個按鈕位於我的標記中,但在代碼隱藏中無法訪問,直到我將其添加到頁面的設計器。現在,當我運行頁面並檢查ID是否需要啓用或禁用按鈕時,出現錯誤,提示「對象引用未設置爲對象的實例」。我不知道爲什麼它扔了。在設計器中添加了按鈕引用,並在代碼隱藏中拋出空錯誤
這是我投入的設計師,所以我可以訪問按鈕
/// <summary>
/// Added this so i can access this button in the code behind
/// </summary>
protected global::DevExpress.Web.ASPxButton xbtnDelete;
/// <summary>
/// Added this so i can access it in the codebehind
/// </summary>
protected global::DevExpress.Web.ASPxButton xbtnView;
這是標記的按鈕
<dx:GridViewDataColumn VisibleIndex="0" Caption="" FieldName="Delete" Width="100" CellStyle-HorizontalAlign="Center">
<DataItemTemplate>
<dx:ASPxButton ID="xbtnDelete" runat="server" Text="Delete" OnClick="xbtnDelete_Click"
CommandArgument='<%# Container.VisibleIndex%>' Theme="Office2010Silver">
<Image IconID="edit_delete_16x16" ToolTip="Edit"></Image>
<ClientSideEvents Click="function(s, e) {e.processOnServer = confirm('Are you sure you want to delete this record?');}" />
</dx:ASPxButton>
</DataItemTemplate>
</dx:GridViewDataColumn>
<dx:GridViewDataColumn VisibleIndex="0" Caption="" FieldName="View" Width="100" CellStyle-HorizontalAlign="Center">
<DataItemTemplate>
<dx:ASPxButton ID="xbtnView" runat="server" Text="View" OnClick="xbtnView_Click"
CommandArgument='<%# Container.VisibleIndex%>' Theme="Office2010Silver">
<Image IconID="miscellaneous_viewonweb_16x16" ToolTip="Edit"></Image>
</dx:ASPxButton>
</DataItemTemplate>
</dx:GridViewDataColumn>
這是我趕上了代碼的代碼錯誤
private void CheckRoleLevel(int roleid)
{
if (RoutingControler.CheckMyRolesAreHigherOrEqualThanComparedRole(Convert.ToInt32(roleid)).Equals(true))
{
xbtnDelete.Enabled = true;
xbtnView.Enabled = true;
}
else
{
xbtnDelete.Enabled = false;
xbtnView.Enabled = false;
}
}
關於我在做什麼的任何想法都是錯誤的?