2
的命令我有下面的代碼如何調用拉德電網
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="Delete" Text="Remove »"
CommandArgument='<%# Eval("ApartmentId") %>'
CommandName="RemoveItem" CssClass="Button" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
和.CS代碼弧度格如下
protected void radGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Page")
{
}
else
{
if (e.CommandName == "RemoveItem")
{
Apartments apartAdmin = new Apartment();
bool deleted = apartAdmin.Delete(int.Parse(e.CommandArgument.ToString());
if (deleted)
{
radGrid.Rebind();
}
}
}
}
我的問題是,當我調試它,說我爲這個事件添加斷點,它從來沒有被解僱,就好像它由於某種原因沒有看到事件......任何人都可以看到問題可能是什麼?這是網格的頂部
<telerik:RadGrid ID="radGrid" ShowFooter="true" ShowHeader="true" CaptionAlign="Left"
runat="server" ForeColor="Black" CellPadding="4" AutoGenerateColumns="False"
CssClass="Grid" Width="100%" GridLines="None" OnRowCommand="radGrid_RowCommand"
OnNeedDataSource="radGrid_NeedDataSource" AllowPaging="True" AllowSorting="true">
<MasterTableView DataKeyNames="ApartmentID,ApartmentTypeID">
<CommandItemSettings ShowRefreshButton="true" ShowAddNewRecordButton="false" />
<Columns>
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="Delete" Text="Remove »"
CommandArgument='<%# Eval("ApartmentId") %>'
CommandName="RemoveItem" CssClass="Button" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<NoRecordsTemplate>
No related items found</NoRecordsTemplate>
</MasterTableView>
<FooterStyle CssClass="FooterStyle" />
<ItemStyle CssClass="RowStyle" />
<HeaderStyle CssClass="HeaderStyle" />
<AlternatingItemStyle CssClass="AlternatingRowStyle" />
<PagerStyle CssClass="PagerStyle" FirstPageText="First" LastPageText="Last" Mode="NextPrevAndNumeric"
AlwaysVisible="true" />
</telerik:RadGrid>
它怎麼會知道它是刪除哪一行?如果沒有RowCommand本身(使用e.CommandName)例如? – user710502
@ user710502:使用CommandArgument。我看你已經通過它,我將在短期內提供了一個例子。 – Icarus
@ user710502:查看我的示例 – Icarus