gridview中弹窗口(根据不同的条件,弹出不同的窗口)
2009-07-27 14:31
399 查看
//第一种 方式
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;
}
}
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;
}
}
相关文章推荐
- 关于在GridView模版里添加DropDownList实现根据下拉列表的不同选择gridview根据条件筛选显示。
- Js 根据不同浏览器弹出窗口
- Gridview某一列根据不同的条件显示不同颜色的实现(原创)
- js 删除 根据不同情况,弹出不同窗口。
- GridView点击超链接时弹出小窗口
- GridView中根据条件改变颜色
- 根据条件,弹出带确定取消的对话框.
- GridView根据获取的值显示不同值
- js弹出窗口总结6种弹窗方法
- 根据条件动态改变GridView某行或某个单元格的背景色---vb.net
- js弹出窗口总结6种弹窗方法
- wicket:根据条件加载不同的form表单数据
- 在GridView中,不同条件的行显示不同的颜色
- 根据内容自动调整弹出窗口大小的JS解决方案
- PlaceHoder控件根据不同条件加载相应自定义控件
- 根据条件动态改变GridView某行或某个单元格的背景色
- 1、根据存入条件操作不同sql语句。
- 在VS.NET中根据条件设置不同的MainForm
- Asp.net弹出新窗口,在gridview 获取值并返回值