如何在ASP.NET中将两个ID从一个页面传递到另一个页面 [英] How to pass the two ID's from one page to another page in ASP.NET

查看:111
本文介绍了如何在ASP.NET中将两个ID从一个页面传递到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Db表名是tblTransaction ..我的第一页是order.aspx,我有我的TableId,TableSeatI ...我想在print.aspx页面中找到这些值....所以你可以访问这些id& ;从他们那里记录.. ????请帮帮我



我尝试了什么:



i不知道怎么样将id从一个页面转换为另一个

My Db table name is tblTransaction.. N my first page is order.aspx on which i have my TableId,TableSeatI... these values i want in print.aspx page.... so ho can access these id's & from them there records..???? please help me

What I have tried:

i dont know how to transform id from one page to another

推荐答案

最简单干净的方法是将这些字段值作为查询字符串发送到URL中。我假设您从order.aspx打开print.aspx页面。



例如print.aspx?TableId = {TableIdValue}& TableSeatId = {TableSeatIdValue}



此URL可以在服务器和客户端(JS)上创建。
The simplest and clean way is to send these field values as query strings in URL. I assume you are opening print.aspx page from order.aspx.

e.g. print.aspx?TableId={TableIdValue}&TableSeatId={TableSeatIdValue}

This URL can be created on server as well as client side (JS).


您可以将ID存储在会话变量中,然后在任何地方调用它!



You could store the ID inside a Session Variable and then call it wherever you want!

var Id1;
var Id2;
Session["FirstID"] = Id1;
Session["SecondID"] = Id2;



如果您想在另一页上打电话,那么您就这样做了:




If you would like to call it then on another page then you siply do this:

var GetID1 = Convert.ToInt32(Session["FirstID"]);
var GetID2 = Convert.ToInt32(Session["SecondID"]);





这些值将从Session中检索并放入GetID1,GetID2变量..



我希望这可以帮到你!



The values will be retrieved from the Session and put inside GetID1,GetID2 Variables..

I hope this helps you out!


这篇关于如何在ASP.NET中将两个ID从一个页面传递到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆