在ASP.NET VB中将参数从一个页面保持到另一个页面 [英] Keeping parameter from one page to another in ASP.NET VB

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

问题描述

我在ASP.NET网站上有一个初始页面,它使用gridcontrol列出一组记录,每行都有一个指向另一个页面的链接,其中一个参数通过查询字符串传递,非常标准的东西。

我使用作为参数传递的id更新第二个详细信息页面上的其他一些字段。

问题是我想在第二页(Detail01.aspx)中嵌入一个链接,将相同的id传递给另一个页面(Detail02.aspx),以便进一步更新。

我在第一个起始页面使用以下内容(MasterList.aspx):

< asp:HyperLinkField DataNavigateUrlFields =Episode_KeyDataNavigateUrlFormatString =Detail01.aspx?Episode_Key = {0 }Text =Details/>

在第二页中,我有以下内容:

< selectparameters>

< asp :QueryStringParameter Name =Episode_KeyQueryStringField =Episode_KeyType =StringDefaultValue =/>



哪个用于另一个选择和更新。

我想把这个id(Episode_Key)传递给另一个页面(Detail02.aspx)。

我在第二页的Formview中尝试了类似的东西:

< asp:HyperLink runat = server Text =Detail02NavigateUrl ='〜/ Detail02.aspx?Episode_Key =<%#Eval(Episode_Ke y)%>'/>

其中我的代码落后:

受保护的子Page_Load(ByVal sender As Object,ByVal e As System.EventArgs)处理我。加载

Episode_Key.Value = Request.QueryString(Episode_Key)。ToString()

结束子

主要问题是我没有多年来我做过这种类型的编码,而且我很生气,很沮丧,这就是为什么我发布了这个问题,希望某种灵魂可以提供答案。

是的,我一直在互联网上查看很多不同的网站。



我很高兴使用隐藏字段或会话变量,或者甚至只是查询字符串参数将id从一个页面传递到另一个页面。



我尝试了什么:



我在第二页的Formview中尝试了类似的东西:

< asp:HyperLink runat = server Text =Detail02NavigateUrl ='〜/ Detail02 .aspx?Episode_Key =<%#Eval(Episode_Key)%>'/>

其中我的代码落后:

受保护的子Page_Load(ByVal sender As Object,ByVal e As System.EventArgs)Handles Me.Load

Episode_Key.Value = Request.QueryString(Episode_Key)。ToString()

End Sub<

I have an initial page on an ASP.NET website that uses gridcontrol to list a set of records, each row has a link to another page, where a parameter is passed via a querystring, pretty standard stuff.
I update some other fields on this second details page using the id passed as the parameter.
The problem is that I want to embed a link into this second page (Detail01.aspx), that passes the same id to another page (Detail02.aspx), for further updates.
I'm using the following in the first starting page (MasterList.aspx):
<asp:HyperLinkField DataNavigateUrlFields="Episode_Key" DataNavigateUrlFormatString="Detail01.aspx?Episode_Key={0}" Text="Details" />
In the second page I have the following:
<selectparameters>
<asp:QueryStringParameter Name="Episode_Key" QueryStringField="Episode_Key" Type="String" DefaultValue="" />

Which is used for both another select and update.
I want to then pass on this id (Episode_Key) to another page (Detail02.aspx).
I have tried something like this inside the second page’s Formview:
<asp:HyperLink runat=server Text="Detail02" NavigateUrl='~/Detail02.aspx?Episode_Key=<%# Eval("Episode_Key") %>' />
where my code behind :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Episode_Key.Value = Request.QueryString("Episode_Key").ToString()
End Sub
The main problem is that I haven't done this type of coding for years, and I'm very rusty, and frustrated, which is why I've posted this question, in the hope that some kind soul might provide an answer.
And yes, I have been looking at many various sites on the internet.

I’m happy to use hiddenfields, or session variables, or even just querystring parameter to pass on the id from one page to another.

What I have tried:

I have tried something like this inside the second page’s Formview:
<asp:HyperLink runat=server Text="Detail02" NavigateUrl='~/Detail02.aspx?Episode_Key=<%# Eval("Episode_Key") %>' />
where my code behind :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Episode_Key.Value = Request.QueryString("Episode_Key").ToString()
End Sub<

推荐答案

如果 Episode_Key FormView 的数据来源:

If the Episode_Key is a column returned by your FormView's data source:
<asp:HyperLink runat=server Text="Detail02" 
    NavigateUrl='<%# Eval("Episode_Key", "~/Detail02.aspx?Episode_Key={0}") %>' 
/>



如果它只存在于查询字符串中:


If it only exists in the query-string:

<asp:HyperLink runat=server Text="Detail02" 
    NavigateUrl='<%# String.Format("~/Detail02.aspx?Episode_Key={0}", Request.QueryString("Episode_Key")) %>' 
/>

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

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