私は本当に苛立たしい問題を追い詰めようとしてきました。最初は、起動していなかったRowDataBoundイベントでしたが、グリッドビュー全体を書き換えた後、Sortingイベントになりました。今回は、ハンドラーがイベントに登録されていないことについて文句を言います。これは嘘です!!!!!!!!私は多くのことを試みました、そして私はこの時点で私は本当に何が起こっているのか分かりません。どんな助けでも大いに感謝されるでしょう。
protected void ContactsSGV_Sorting2(object sender, GridViewSortEventArgs e)
{
var PLEASE_WORK = true;
}
<CC:SortableGridView runat="server" ID="ContactsSGV" Width="100%" DataKeyNames="ContactID,ContactType"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="false" OnRowDataBound="ContactsSGV_RowDataBound"
OnPageIndexChanging="ContactsSGV_PageIndexChanging" OnSorting="ContactsSGV_Sorting2">
<Columns>
<CC:SortableBoundField HeaderText="First Name" DataField="FirstName" SortExpression="FirstName"
DefaultImageUrl="~/Images/sortable.png" AscImageUrl="~/Images/arrow-up.png" DescImageUrl="~/Images/arrow-dn.png"
meta:resourcekey="BoundFieldFirstNameResource1" ItemStyle-Width="15%" />
<CC:SortableBoundField DataField="MiddleName" HeaderText="Middle Name" SortExpression="MiddleName"
DefaultImageUrl="~/Images/sortable.png" AscImageUrl="~/Images/arrow-up.png" DescImageUrl="~/Images/arrow-dn.png"
meta:resourcekey="BoundFieldMiddleNameResource1" ItemStyle-Width="15%" />
<CC:SortableBoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName"
DefaultImageUrl="~/Images/sortable.png" AscImageUrl="~/Images/arrow-up.png" DescImageUrl="~/Images/arrow-dn.png"
meta:resourcekey="BoundFieldLastNameResource1" ItemStyle-Width="15%" />
<CC:SortableBoundField DataField="Company" HeaderText="Company" SortExpression="LastName"
DefaultImageUrl="~/Images/sortable.png" AscImageUrl="~/Images/arrow-up.png" DescImageUrl="~/Images/arrow-dn.png"
meta:resourcekey="BoundFieldCompanyResource1" ItemStyle-Width="15%" />
<CC:SortableBoundField DataField="Email" HeaderText="Email" SortExpression="Email"
meta:resourcekey="BoundFieldEmailResource1" DefaultImageUrl="~/Images/sortable.png"
AscImageUrl="~/Images/arrow-up.png" DescImageUrl="~/Images/arrow-dn.png" ItemStyle-Width="16%" />
<CC:SortableBoundField DataField="Phone" HeaderText="Work Phone" SortExpression="Phone"
DefaultImageUrl="~/Images/sortable.png" AscImageUrl="~/Images/arrow-up.png" DescImageUrl="~/Images/arrow-dn.png"
meta:resourcekey="BoundFieldPhoneResource1" ItemStyle-Width="14%" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ViewButton" runat="server" Width="25px" Height="30px" ToolTip="View"
CommandName="Select" CommandArgument='<%# Eval("ContactID") %>' ImageUrl="~/Images/View_24.png"
meta:resourcekey="GVBtnViewResource1" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="5%" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="EditButton" runat="server" Width="25px" Height="30px" ToolTip="Edit"
CommandName="Edit" ImageUrl="~/Images/Edit_32x32.png" meta:resourcekey="GVBtnEditResource1" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="5%" />
</asp:TemplateField>
</Columns>
</CC:SortableGridView>
System.Web.HttpException was unhandled by user code
Message=The GridView 'ContactsSGV' fired event Sorting which wasn't handled.
Source=System.Web
ErrorCode=-2147467259
WebEventCode=0
StackTrace:
at System.Web.UI.WebControls.GridView.OnSorting(GridViewSortEventArgs e)
at CustomControls.SortableGridView.OnSorting(GridViewSortEventArgs e) in E:\Local\ProTrackPlus_GroupBy2+\CustomControls\SortableGridView.cs:line 314
at System.Web.UI.WebControls.GridView.HandleSort(String sortExpression, SortDirection sortDirection)
at System.Web.UI.WebControls.GridView.HandleSort(String sortExpression)
at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
at System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
protected void ContactsSGV_RowDataBound(object sender, GridViewRowEventArgs e)
{
//THIS ONE WORKS
var isItWorking = "YES IT IS OMG ";
}
protected void ContactsSGV_Sorting2(object sender, GridViewSortEventArgs e)
{
//THIS IS HELL!
var PLEASE_WORK = true;
}
public class SortableGridView : GridView{
//STUFF
}
protected override void OnSorting(GridViewSortEventArgs e)
{
//This is inside my SortableGridView Class.
//As you can see I am calling the base method and this in fact DOES WORK
//Is my Handler on a page using this control that does not handle the raised event.
setSortData(e.SortExpression);
base.OnSorting(e);
}
サードパーティのコントロールにさらに注意を向けないようにするために、グリッドビューを通常のaspビューに戻しました。これが今の構造です。......注:リンクを追加するには評判が不十分です:(