<asp:LinkButton CommandName="RePublish" id="btnRePublish" runat="server">重发</asp:LinkButton>

解决方案 »

  1.   

    在Datagrid的ItemCommand事件中触发
      

  2.   

    Datagrid的ItemCommand内
    if(e.CommandName="RePublish")
     { .............}
      

  3.   

    唉.........在设计页面选中 Datagrid ,然后选属性 --> 事件双击 ItemCommand 后的空白部分这时会自动转到代码页面在里面写
    if(e.CommandName == "RePublish")
    {
    .....你想要实现的逻辑.....
    }
    就可以了
      

  4.   

    int id=int.Parse(dgComInfo.DataKeys[e.Item.ItemIndex].ToString());
    if(e.CommandName.Equals("delete"))
    {
    bool result=c.DeleteComInfo(id);
    string str=((TextBox)e.Item.FindControl("TextBox1")).Text;
    string imagepath=Server.MapPath("")+"\\Images\\"+str;
    if(System.IO.File.Exists(imagepath))
    {
    System.IO.File.Delete(imagepath);
    }
    if(result)
    {
    RegisterStartupScript("Succeed","<script>alert('企业名录删除成功')</script>");
    BindData();
    }
    }
    else if(e.CommandName.Equals("update"))
    {
    Response.Redirect("UpdateComInfo.aspx?cid="+id+"");
    }
    else if(e.CommandName.Equals("vouch"))
    {
    Response.Redirect("VouchComInfo.aspx?cid="+id+"");
    }这是在DataGrid_ItemCommand事件中实现的
    有删除、修改和推荐,但一定要设CommandName属性
      

  5.   

    触发Datagrid的ItemCommand事件
    然后在这个事件中判断具体是那个按钮触发的,然后进行相应的处理if(e.CommandName="RePublish")
     { .............}