Telerik RadGrid上的确认对话框
本文关键字:确认 对话框 RadGrid Telerik | 更新日期: 2023-09-27 18:21:09
我正试图在telerik rad网格中添加一个确认对话框,但遇到了问题。它导致事件页面格式错误突然出现。我有下面的RadGrid,当我将其设置为true时,它不会删除行,所以我不知道出了什么问题。有人能帮忙吗?
<telerik:RadGrid ID="grdSoccerPlayers" runat="server" AutoGenerateColumns="False" DataSourceID="entyPlayer" GroupPanelPosition="Top" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" OnItemCommand="grdSoccerPlayers_ItemCommand" CellSpacing="-1" GridLines="Both" AllowAutomaticDeletes="True">
<MasterTableView DataSourceID="entyPlayer" CommandItemDisplay="Top" DataKeyNames="id">
<Columns>
<telerik:GridBoundColumn DataField="player_id" FilterControlAltText="Filter player_id column" HeaderText="player_id" ReadOnly="True" SortExpression="player_id" UniqueName="player_id">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="fname" FilterControlAltText="Filter fname column" HeaderText="fname" ReadOnly="True" SortExpression="fname" UniqueName="fname">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="lname" FilterControlAltText="Filter lname column" HeaderText="lname" ReadOnly="True" SortExpression="lname" UniqueName="lname">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="telephone" FilterControlAltText="Filter telephone column" HeaderText="telephone" ReadOnly="True" SortExpression="telephone" UniqueName="telephone">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="email" FilterControlAltText="Filter email column" HeaderText="email" ReadOnly="True" SortExpression="email" UniqueName="email">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn DataField="active" DataType="System.Boolean" FilterControlAltText="Filter active column" HeaderText="active" ReadOnly="True" SortExpression="active" UniqueName="active">
</telerik:GridCheckBoxColumn>
<telerik:GridBoundColumn DataField="createdDate" FilterControlAltText="Filter createdDate column" HeaderText="createdDate" ReadOnly="True" SortExpression="createdDate" UniqueName="createdDate" DataType="System.DateTime">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="author" FilterControlAltText="Filter author column" HeaderText="author" ReadOnly="True" SortExpression="author" UniqueName="author">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="siteid" FilterControlAltText="Filter siteid column" HeaderText="siteid" ReadOnly="True" SortExpression="siteid" UniqueName="siteid" DataType="System.Guid">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="gender" FilterControlAltText="Filter gender column" HeaderText="gender" ReadOnly="True" SortExpression="gender" UniqueName="gender">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="id" DataType="System.Guid" FilterControlAltText="Filter id column" HeaderText="id" ReadOnly="True" SortExpression="id" UniqueName="id">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete"
ButtonType="ImageButton" ImageUrl="~/Icons/delete.png" AutoPostBackOnFilter="true"
ConfirmTitle="Delete" ConfirmDialogType="Classic"
ConfirmText="Are you sure want to delete the selected report?" />
</Columns>
</MasterTableView>
</telerik:RadGrid><telerik:RadWindow ID="rdConfim" runat="server"></telerik:RadWindow>
然后在我的代码后面是下面的
protected void grdSoccerPlayers_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if(e.CommandName == RadGrid.InitInsertCommandName)
{
Guid strId = Guid.Empty;
Response.Redirect("edit.aspx?id=" + strId.ToString());
}
if (e.CommandName == "Edit")
{
GridDataItem item = e.Item as GridDataItem;
Guid strId = new Guid(item.GetDataKeyValue("id").ToString());
Response.Redirect("edit.aspx?id=" + strId.ToString());
}
if (e.CommandName == RadGrid.InitInsertCommandName)
{
Response.Redirect("edit.aspx");
}
if(e.CommandName ==RadGrid.DeleteCommandName)
{
GridDataItem item = e.Item as GridDataItem;
Guid strId = new Guid(item.GetDataKeyValue("id").ToString());
player _player = _dal.GetPlayerBYID(strId);
_dal.SoccerEntities.players.DeleteObject(_player);
_dal.SoccerEntities.SaveChanges();
grdSoccerPlayers.DataBind();
}
}
但它根本没有删除这一行——它只是停留在纪念中。我必须补充一下,当我点击自动签名的时候,它工作得很好。
调用grdSoccerPlayers.Rebind();
方法。这将使网格再次从数据源请求其数据。DataBind
方法的用途非常有限。