如题:代码如下
<Grid Name="MenuDropDetail" Height="80" VerticalAlignment="Bottom" Width="855" > <Grid.ContextMenu> <ContextMenu > <MenuItem Tag="{Binding ID}" Name="Openmenu" IsEnabled="{Binding State,Converter={StaticResource IndexSoftlistMenuConverter}}" Header="打开软件" Click="Openmenu_Click" /> <MenuItem Tag="{Binding ID}" Name="Updatemenu" IsEnabled="{Binding State,Converter={StaticResource IndexSoftlistUpdateConverter}}" Header="修复" Click="Updatemenu_Click" /> <MenuItem Tag="{Binding ID}" Name="Loadmenu" IsEnabled="{Binding State,Converter={StaticResource IndexSoftlistMenuAnzhuangConverter}}" Header="安装软件" Click="Loadmenu_Click" /> <MenuItem Tag="{Binding ID}" Name="Upmenu" IsEnabled="{Binding State,Converter={StaticResource IndexSoftlistMenuUpConverter}}" Header="升级软件" Click="Upmenu_Click" /> <Separator /> <MenuItem Tag="{Binding ID}" Header="查看详情" Click="MenuItem_Click_Detail" /> </ContextMenu> </Grid.ContextMenu>
现在有个
Updatemenu_Click事件,当我点击的时候想获取这个MenuItem的父控件Grid,百度了一大圈,一时找不到,不知道怎么去获取
var mi = sender as MenuItem;
var cm = mi.Parent as ContextMenu;
var grid = cm.PlacementTarget as Grid;
多谢多谢
正解
没有仔细看,给你点代码
<asp:LinkButton ID="LinkButtonClick" runat="server" CommandArgument='<%#Eval("ChuFaXH") %>'
OnClientClick="return confirm('是否删除?')" OnClick="LinkButtonDel_Click" CssClass="IsShanChu">删除</asp:LinkButton>
protected void LinkButtonDel_Click(object sender, EventArgs e)
{
string id = Convert.ToString((sender as LinkButton).CommandArgument);
BLL.Info_ChangSuoCFBLL bll = new BLL.Info_ChangSuoCFBLL();
bool del = bll.Delete(id);
if (del)
{
string type = Convert.ToString(Request["type"]);
string script = string.Format("<script type='text/javascript'>alert('删除成功');location.href='Info_ChangSuoFaAnList.aspx?type={0}';</script>", type);
this.ClientScript.RegisterStartupScript(this.GetType(), "aa", type);
}
else
{
this.ClientScript.RegisterStartupScript(this.GetType(), "aa", "<script type='text/javascript'>alert('删除失败');</script>");
}
}
直接用Grid的Name不行么