我目前正在评估 Telerik 的一些 RAD 控件,现在我正在尝试 RadGrid。
所以我有了网格控件并启用了客户端绑定(bind)以获得 Ajax 支持。我创建了一个适当的 WCF Web 服务来获取数据等。一切都运行得很好,包括分页等。现在我想要一个用于删除某些项目的按钮列。我注册了网格的 OnItemCommand 事件并在服务器端相应地实现了它。我的 ASPx 代码如下所示:
<telerik:RadGrid runat="server" ID="RadGrid1" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" GridLines="None"
OnItemCommand="RadGrid1_ItemCommand">
<MasterTableView DataKeyNames="Id" ClientDataKeyNames="Id">
<Columns>
<telerik:GridBoundColumn DataField="Firstname" HeaderText="Firstname" DataType="System.String">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Lastname" HeaderText="Lastname" DataType="System.String">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Age" HeaderText="Age" DataType="System.Int32">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"
ButtonType="ImageButton">
</telerik:GridButtonColumn>
</Columns>
<PagerStyle Mode="Slider" />
</MasterTableView>
<ClientSettings>
<DataBinding SelectMethod="GetSampleData" Location="Webservice/GridData.svc" SortParameterType="String">
</DataBinding>
</ClientSettings>
</telerik:RadGrid>
但是,当单击网格行上的相应按钮时,不会触发该事件,基本上没有向服务器进行回发。我找到的解决方案是将“EnablePostBackOnRowClick=true
”添加到 ClientSettings,但这会导致每次单击一行时都会发生回发,这并不是真正需要的。
有没有更好的方法来实现这一点,或者有人暗示可能是什么问题?
谢谢
最佳答案
鉴于答案from the Telerik forum,这似乎是不可能的.
关于asp.net - RadGrid 不会在 ItemCommand 事件上触发回发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1554633/