WEB开发网
开发学院WEB开发ASP.NET gridview中弹窗口(根据不同的条件,弹出不同的窗... 阅读

gridview中弹窗口(根据不同的条件,弹出不同的窗口)

 2009-10-25 17:26:03 来源:WEB开发网   
核心提示://第一种 方式 PRotected void RecAmtGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { string billNo = RecAmtGridView.Rows[e.NewSelectedInd

//第一种 方式
   PRotected void RecAmtGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
   {
     string billNo = RecAmtGridView.Rows[e.NewSelectedIndex].Cells[3].Text;
     string billType = RecAmtGridView.Rows[e.NewSelectedIndex].Cells[2].Text;
     if (billType =="进货")
     {
       Response.Redirect("TS_HqReceiveReg.aspx?Action=3&fBillNo=" + billNo);
       ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, UpdatePanel1.GetType(), "进货", "window.open('TS_HqReceiveReg.aspx?Action=3&fBillNo=" + billNo + "')", true);
     }
     else if (billType == "退货")
     {
       Response.Redirect("TS_HqReturnReg.aspx?Action=3&fBillNo=" + billNo);
       ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, UpdatePanel1.GetType(), "进货", "window.open('TS_HqReturnReg.aspx?Action=3&fBillNo=" + billNo + "')", true);

   }
     else
     {
       Response.Redirect("CostRegView.aspx?Action=3&fBillNo=" + billNo);
       ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, UpdatePanel1.GetType(), "进货", "window.open('CostRegView.aspx?Action=3&fBillNo=" + billNo + "')", true);

   }

   }

   //第二种方式: 加入模板列
  <asp:TemplateField HeaderText="单据编号">
   <ItemTemplate>
   <asp:LinkButton ID="lbRecAmtBill" CommandName="lbRecAmtBill"  Text='<%#Eval("fBillNo")%>'  runat="server"></asp:LinkButton>
   </ItemTemplate>
 </asp:TemplateField>

   protected void RecAmtGridView_RowCommand(object sender, GridViewCommandEventArgs e)
   {
     GridViewRow GridViewRow1 = (GridViewRow)((Control)e.CommandSource).Parent.Parent;

   LinkButton lbbutton = GridViewRow1.FindControl("lbRecAmtBill") as LinkButton;
     string billNo = lbbutton.Text;
     string billType = GridViewRow1.Cells[2].Text;
     if (billType == "进货")
     {
       ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, UpdatePanel1.GetType(), "进货", "window.open('TS_HqReceiveReg.aspx?Action=3&fBillNo=" + billNo + "')", true);
     }
     else if (billType == "退货")
     {
       ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, UpdatePanel1.GetType(), "退货", "window.open('TS_HqReturnReg.aspx?Action=3&fBillNo=" + billNo + "')", true);

   }
     else
     {
       ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, UpdatePanel1.GetType(), "费用", "window.open('CostRegView.aspx?Action=3&fBillNo=" + billNo + "')", true);

   }

   }


   //第三种方式
  <asp:HyperLinkField HeaderText="单据编号" Text="单据编号"  Target="mainframe" NavigateUrl="" DataTextField="fBillNo" >
  </asp:HyperLinkField>

   protected void PayAmtGridView_RowDataBound(object sender, GridViewRowEventArgs e)
   {

   if (e.Row.RowIndex >= 0)
     {

     sumRealAmt += Convert.ToDouble(e.Row.Cells[3].Text);
       sumDiscAmt += Convert.ToDouble(e.Row.Cells[4].Text);
       sumTotAmt += Convert.ToDouble(e.Row.Cells[5].Text);
       sumInvAmt += Convert.ToDouble(e.Row.Cells[6].Text);

   }
     else if (e.Row.RowType == DataControlRowType.Footer) 每列汇总求和
     {
       e.Row.Cells[2].Text = "总计:";
       e.Row.Cells[3].Text = sumRealAmt.ToString();
       e.Row.Cells[4].Text = sumDiscAmt.ToString();
       e.Row.Cells[5].Text = sumTotAmt.ToString();
       e.Row.Cells[6].Text = sumInvAmt.ToString();

   }

   绑定转向页面
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
       必须将HyperLinkField 转化为 HyperLink 才能进行操作
       HyperLink linkField = (HyperLink)e.Row.Cells[3].Controls[0];
       billNo = linkField.Text ;
       billType = e.Row.Cells[2].Text;

     if (billType == "进货")
       {
         url = "TS_HqReceiveReg.aspx?Action=3&fBillNo=" + billNo + "";
       }
       else if (billType == "退货")
       {
         url = "TS_HqReturnReg.aspx?Action=3&fBillNo=" + billNo + "";

     }
       else
       {
         url = "CostRegView.aspx?Action=3&fBillNo=" + billNo + "";

     }

     linkField.NavigateUrl = url;
     }

   }

Tags:gridview 中弹 窗口

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接