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

王朝学院·作者佚名  2009-10-28
窄屏简体版  字體: |||超大  

//第一种 方式

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;

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航