如何在下一页中显示所选iteam的值 [英] how can i display the value of a selected iteam in next page
问题描述
你好我有一个小问题
我是一个电枢程序员我问一个狡猾的问题...我有一个任务我有一个下拉列表,公司名称来自db。 ..他们有一个id ....当我选择一个特定的公司并按提交....然后id必须去设置在公司ID文本框但它应该是可编辑的... plz do send我需要在frnt页面和背景中编写吗?
hello i have a small problem
i'm a armature programmer im asking a sillly question... i have a task i have a drop down list in which the company names come from db... they have a id to it.... when i select a particular company and press submit.... then the id has to go and set in the company id text box but it should be editable... plz do send wht i need to write in the frnt page and as well as background?
推荐答案
将你的id存储在会话中并使用其他页面简单
store your id in session and use other page simple
你可以使用查询字符串将值从1页传递给另一页。
在你的第一页 - >
U can use Query String To Pass value form 1 page to another .
In your First page ->
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Page1.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
</head>
<body>
<form id="form1" runat="server" >
<asp:DropDownList id="DropDownList1" runat="server" >
<asp:ListItem value="">Select</asp:ListItem>
<asp:ListItem value="1">Hello</asp:ListItem>
<asp:ListItem value="2">World</asp:ListItem>
</asp:DropDownList>
<asp:button id="btnSubmit" onclick="btnSubmit_OnClick" Text="Click Me" Runat="server"></asp:button>
</form>
</body>
</html>
.cs(第1页后面的代码)
.cs(code behind For 1st page)
protected void btnSubmit_OnClick(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem.Value.Length > 0)
{
Response.Redirect("Page2.aspx?SelectedValue=" + DropDownList1.SelectedValue);
}
}
in第二页创建文本框并在代码后面编写以下代码
.cs(后面的第2页代码)
in second page Create textbox and write following code in code bihind
.cs(2nd page code behind )
protected void Page_Load(object sender, EventArgs e)
{
string v = Request.QueryString["SelectedValue"];
}
它可以通过多种方式完成你可以使用SESSION,或者你可以通过javascript完成,如果你想完成这个任务客户端。
只需通过谷歌并通过会话或javascript搜索他们的任务你就可以在那里得到很好的解决方案..
it can be done through many ways u can u use SESSION or u can done through the javascript if u want to do this task over the client side.
just go through the google and search their this task by session or javascript u can get good solution over there..
>
这篇关于如何在下一页中显示所选iteam的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!