【发布时间】:2016-12-08 10:56:39
【问题描述】:
所以,我有一个具有典型编辑安排的 RadGrid,它正在工作……但现在不行。永远不要触发 UpdateCommand 事件,在那里设置一个断点并且它没有被到达。让我发疯,因为它一直工作得很好,我想不出我做过的任何事情会导致它。当我单击编辑时,表单打开得很好,取消按钮有效,但更新命令永远不会触发。 在网格中我有:
OnUpdateCommand="pendingVehiclesRadGrid_UpdateCommand"
And in my code behind I have:
protected void pendingVehiclesRadGrid_UpdateCommand(object source, GridCommandEventArgs e)
{
blah blah
}
看起来很简单,但正如我所说......什么都没有。如果有新视野的人能提出建议,我将一如既往地感激不尽。
编辑以添加 XML:
<telerik:RadGrid ID="pendingVehiclesRadGrid" runat="server" AutoGenerateColumns="False"
CellSpacing="0" GridLines="None" AllowPaging="True"
DataMember="ID"
onneeddatasource="pendingVehiclesRadGrid_NeedDataSource"
OnUpdateCommand="pendingVehiclesRadGrid_UpdateCommand" PageSize="20"
onitemcommand="pendingVehiclesRadGrid_ItemCommand" >
<MasterTableView DataKeyNames="status,charity,make,model,year,vin,date,id,salePrice,bid,note"
EditMode="EditForms">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridButtonColumn CommandName="History" Text="History" UniqueName="detailBtn" HeaderText="History" HeaderButtonType="PushButton" AutoPostBackOnFilter="True">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn HeaderText="Charity" ItemStyle-Width="140px" FilterControlAltText="Filter column2 column"
UniqueName="column3" DataType="System.String" DataField="charity" ReadOnly="True">
<ItemStyle Width="140px"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="VIN" ItemStyle-Width="140px" FilterControlAltText="Filter column6 column"
UniqueName="column7" DataType="System.String" DataField="vin" >
<ItemStyle Width="140px"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Year" ItemStyle-Width="140px" FilterControlAltText="Filter column2 column"
UniqueName="column2" DataType="System.Int32" DataField="year">
<ItemStyle Width="140px"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Make" ItemStyle-Width="140px" FilterControlAltText="Filter column column"
UniqueName="column" DataType="System.String" DataField="make">
<ItemStyle Width="140px"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Model" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
UniqueName="column1" DataType="System.String" DataField="model">
<ItemStyle Width="140px"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Last Update" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
UniqueName="column5" DataType="System.DateTime" DataField="date" ReadOnly="True">
<ItemStyle Width="140px"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Min. Bid" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
UniqueName="column8" DataType="System.Decimal" DataField="bid" DataFormatString="{0:C}" >
<ItemStyle Width="140px"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Sale Price" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
UniqueName="column6" DataType="System.Decimal" DataField="salePrice" DataFormatString="{0:C}" Display="False">
<ItemStyle Width="140px"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Notes" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
UniqueName="unsoldNotesColumn" DataType="System.String" DataField="note" Display="True">
<ItemStyle Width="140px"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Latest Status" ItemStyle-Width="240px">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "Status")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox RenderMode="Lightweight" runat="server" ID="pendingVehiclesRadGridupdateComboBox" DataTextField="Status"
DataValueField="ID" DataSourceID="LinqDataSource1" >
</telerik:RadComboBox>
</EditItemTemplate>
<ItemStyle Width="240px"></ItemStyle>
</telerik:GridTemplateColumn>
<telerik:GridEditCommandColumn FooterText="EditCommand footer" UniqueName="pendingVehiclesRadGridEditCommandColumn"
HeaderText="Edit" HeaderStyle-Width="100px" UpdateText="Update">
<HeaderStyle Width="100px"></HeaderStyle>
</telerik:GridEditCommandColumn>
</Columns>
<EditFormSettings EditColumn-DataType="System.String">
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
【问题讨论】:
-
请显示您的 RadGrid 的整个 XAML。我认为您的命令按钮有问题。
-
@modiX 我是新来的……如何将整个内容发布到 cmets 中?对不起:(
-
@PaulBinCT2 您可以编辑您的问题,而不是将其放入 cmets
-
要检查的事项:1) 您正确使用了 NeedDataSource,并且您没有在代码中的其他任何地方手动绑定 RadGrid 2) 您的 RadGrid 标记是正确的
-
@Scotty 我当然可以检查,但它会导致更新命令根本不触发吗?
标签: c# asp.net webforms telerik