Click here to Skip to main content
13,004,839 members (62,151 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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?
Posted 25-Jul-13 20:56pm
Vamna441
Comments
dholakiya ankit 26-Jul-13 4:32am
   
use state management
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

store your id in session and use other page simple
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 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(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 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"];
    }
  Permalink  
Comments
Vamna 26-Jul-13 4:33am
   
i told the list in drop down is gettin from db.... here u entered is manual....
vivektiwari97701 26-Jul-13 4:38am
   
so Bind Your DDl with in Page Load event of first page ...Did u Know How to bind DDL to DB ???
if u dont ...ill give u some ref..
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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..
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

<%@ 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>
 

protected void Page_Load(object sender, EventArgs e)
   {
         string v = Request.QueryString["SelectedValue"];
    }
<asp:button id="btnSubmit" onclick="btnSubmit_OnClick" Text="Click Me" Runat="server"></asp:button>
      </form>
    </body>
    </html>





protected void btnSubmit_OnClick(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem.Value.Length > 0)
{
                Response.Redirect("Page2.aspx?SelectedValue=" + DropDownList1.SelectedValue);
}
}




protected void Page_Load(object sender, EventArgs e)
   {
         datatable dt= dbacces.getdatatable("select companyname,companyid from company master ");
if(dt.rows.count>0)
{
DropDownList1.datasource=dt;
DropDownList1.DataTextField=dt.rows[0]["company_name"];
DropDownList1.DataValueField=dt.rows[0]["company_id"];
DropDownList1.databind()
 
}
    }



tell me if not working (:)
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170627.1 | Last Updated 27 Jul 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100