从两个不同的页面获取数据
get data from two different pages
这是我的问题。举例来说,当我点击转发器行 ID 时,它将转移到特定客户的发票。
但是在客户发票页面,它只有在客户ID登录时才会打开。所以这里是两个不同的页面访问一页数据。我的代码如下。
在转发器的页面中。
<th>
<asp:LinkButton ID ="lnkbtnStmt" Text ="Statement" OnClick ="lnkbtnStmt_Click" runat="server"></asp:LinkButton>
<asp:HiddenField ID ="hfStmt" runat ="server" Value='<% #Eval("No")%>'/>
</th>
在转发器 .cs 页面中:
public void lnkbtnStmt_Click(object sender, EventArgs e)
{
int rptIndex = ((RepeaterItem)((LinkButton)sender).NamingContainer).ItemIndex;
string hfItem = Convert.ToString(((HiddenField)RptEmpCustInvoise.Items[rptIndex].FindControl("hfStmt")).Value);
Customer_Ledger_Entries custlist = new Customer_Ledger_Entries();
List<Customer_Ledger_Entries_Filter> cFilter = new List<Customer_Ledger_Entries_Filter>();
Customer_Ledger_Entries_Filter cfield = new Customer_Ledger_Entries_Filter();
cfield.Field = Customer_Ledger_Entries_Fields.Customer_No;
cfield.Criteria = hfItem;
cFilter.Add(cfield);
Customer_Ledger_Entries[] culist = cls.wsCustInvoice.ReadMultiple(cFilter.ToArray(), null, 1);
if (culist.Length > 0)
{
Response.Redirect("frmCustomerInvoice.aspx?Customer_No=" + hfItem);
}
}
并在另一个客户页面中。
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
GetOpeningBal();
bindCustInvoice(objSession.getSession(HttpContext.Current, "NonEmpCode"));
string empCustId = Request.QueryString["Customer_No"];
if (empCustId.Length != 0)
{
CustInvoice("empCustId");
}
GetClosingBal();
}
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), string.Empty, "alert('" + ex.Message.ToString() + "');", true);
}
}
在此页面中,bindCustInvoice()
方法在客户登录时起作用,CustInvoice("empCustId");
方法在我们单击转发器 ID 时起作用。
谁能给我解决方案?
当您单击 Repeater Id 时,尝试从查询字符串发送页面名称。并检查您的另一个客户页面中的页面名称
伪代码
string PageName ="";
if(Request.QueryString["PageName"] != null)
{
PageName= Request.QueryString["PageName"];
}
if(PageName != "")
{
string empCustId = Request.QueryString["Customer_No"];
if (empCustId.Length != 0)
{
CustInvoice("empCustId");
}
}
else{
bindCustInvoice(objSession.getSession(HttpContext.Current, "NonEmpCode"));
}
这是我的问题。举例来说,当我点击转发器行 ID 时,它将转移到特定客户的发票。
但是在客户发票页面,它只有在客户ID登录时才会打开。所以这里是两个不同的页面访问一页数据。我的代码如下。 在转发器的页面中。
<th>
<asp:LinkButton ID ="lnkbtnStmt" Text ="Statement" OnClick ="lnkbtnStmt_Click" runat="server"></asp:LinkButton>
<asp:HiddenField ID ="hfStmt" runat ="server" Value='<% #Eval("No")%>'/>
</th>
在转发器 .cs 页面中:
public void lnkbtnStmt_Click(object sender, EventArgs e)
{
int rptIndex = ((RepeaterItem)((LinkButton)sender).NamingContainer).ItemIndex;
string hfItem = Convert.ToString(((HiddenField)RptEmpCustInvoise.Items[rptIndex].FindControl("hfStmt")).Value);
Customer_Ledger_Entries custlist = new Customer_Ledger_Entries();
List<Customer_Ledger_Entries_Filter> cFilter = new List<Customer_Ledger_Entries_Filter>();
Customer_Ledger_Entries_Filter cfield = new Customer_Ledger_Entries_Filter();
cfield.Field = Customer_Ledger_Entries_Fields.Customer_No;
cfield.Criteria = hfItem;
cFilter.Add(cfield);
Customer_Ledger_Entries[] culist = cls.wsCustInvoice.ReadMultiple(cFilter.ToArray(), null, 1);
if (culist.Length > 0)
{
Response.Redirect("frmCustomerInvoice.aspx?Customer_No=" + hfItem);
}
}
并在另一个客户页面中。
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
GetOpeningBal();
bindCustInvoice(objSession.getSession(HttpContext.Current, "NonEmpCode"));
string empCustId = Request.QueryString["Customer_No"];
if (empCustId.Length != 0)
{
CustInvoice("empCustId");
}
GetClosingBal();
}
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), string.Empty, "alert('" + ex.Message.ToString() + "');", true);
}
}
在此页面中,bindCustInvoice()
方法在客户登录时起作用,CustInvoice("empCustId");
方法在我们单击转发器 ID 时起作用。
谁能给我解决方案?
当您单击 Repeater Id 时,尝试从查询字符串发送页面名称。并检查您的另一个客户页面中的页面名称
伪代码
string PageName ="";
if(Request.QueryString["PageName"] != null)
{
PageName= Request.QueryString["PageName"];
}
if(PageName != "")
{
string empCustId = Request.QueryString["Customer_No"];
if (empCustId.Length != 0)
{
CustInvoice("empCustId");
}
}
else{
bindCustInvoice(objSession.getSession(HttpContext.Current, "NonEmpCode"));
}