Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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
Comments
Dholakiya Ankit 26-Jul-13 4:32am    
use state management

store your id in session and use other page simple
 
Share this answer
 
U can use Query String To Pass value form 1 page to another .

In your First page ->

ASP.NET
<%@ 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)


C#
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 )

C#
protected void Page_Load(object sender, EventArgs e)
   {
         string v = Request.QueryString["SelectedValue"];
    }
 
Share this answer
 
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..
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..
 
Share this answer
 
XML
<%@ 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>





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




C#
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 (:)
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900