Click here to Skip to main content
13,143,693 members (34,512 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 19:41pm
Rate this: bad
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)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


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>
in .cs page
<pre lang="cs">protected void Department()
        DataTable dt = Display_Logic.display_department_logic();
        ddl_offic_depar.DataSource = dt;

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);

you are create same code in country and i create a ntire architecture
Rate this: bad
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.


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 :)

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 |
Web02 | 2.8.170915.1 | Last Updated 4 Feb 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