Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
i have dropdown list when i insert country from dropdown list it succesfully inserted but on next page i want to show same country which i inserted in db should display on dropdownlist but dropdownlist should locked.
Posted 3-Feb-13 20:41pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

dropdownlist1.enabbled = false;
(at page load event of the next page.)
 
dropdownlist1.Text = (retrieved country name from the database)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

hi
 
create same code
 
in aspx page
 
<asp:DropDownList ID="ddl_offic_depar" runat="server" CssClass="ddl_width" Style="border: 1px solid black;"
                                            DataTextField="dept_name" DataValueField="dept_id" AppendDataBoundItems="true">
                                            <asp:ListItem>--Select Department--</asp:ListItem>
                                        </asp:DropDownList>
 
in .cs page
<pre lang="cs">protected void Department()
    {
        DataTable dt = Display_Logic.display_department_logic();
        ddl_offic_depar.DataSource = dt;
        ddl_offic_depar.DataBind();
    }</pre>
 

in  display logic
<pre lang="cs">public static DataTable display_department_logic()
   {
       SqlCommand cmd = new SqlCommand();
       cmd.CommandText = &quot;display_department_sp&quot;;
       return Create_Command.ExecQuery(cmd);
   }</pre>
 

 
you are create same code in country and i create a ntire architecture
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

you can use one of client side state management technique. i.e querystring
Using querystrings, you can pass the data(in your case it's country that inserted in database) from one page to very next page though url.
 
ex:
http;//www.xxxx.com/default.aspx?countryName=India
or
http;//www.xxxx.com/default.aspx?countryId=12
 
here 12 is the Id, for country in database.
you can read the values from url using following code
string countryName = Request.QueryString["countryName"];
// or
// If you know the id of the country, then again connect to Database and retrieve the value,
// But passsing the value in querystring is best way.. so that you can avoid unnecessary Database hits
int countryid = Convert.ToInt32(Request.QueryString["countryId"]);
 
If you mean locking the Dropdownlist is Disabling or read only.
ddlCountry.SelectedValue = countryName;
ddlCountry.Enabled = false;
Hope it will helps you..
Happy coding Smile | :)
  Permalink  

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

  Print Answers RSS
0 Maciej Los 205
1 Richard MacCutchan 185
2 DamithSL 170
3 Tomas Takac 146
4 OriginalGriff 132
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2014
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