我在gridview中有个模板button,我想做的是当Session["Type"]=1时,点button,可以查看详单,当=2时,弹出对话框,要求登录.=3时....,这些应该写哪呢?

解决方案 »

  1.   

    我不知道写在哪啊,那个button的事件是什么呢?谢谢
      

  2.   

    // .aspx
    <itemtemplate>
    <asp:button commandname="MyCommandName" runat=server />
    <itemtemplate>// .aspx.cs
    protected void GridView1_RowCommand(object sender, GridViewRowCommandEventArgs e){
         swith(e.CommandName) {
             case "MyCommandName":
                int flag = (int)Session["Type"];
               if(flag == 1) {
                  // ....
               }
               else if(flag == 2) {
                  // ...
               } 
               // else .....
               break;
         }
    }