Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem in page Redirect

Problem in page Redirect

Scheduled Pinned Locked Moved ASP.NET
csharphelpdatabasecomsysadmin
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Parameswar Mal
    wrote on last edited by
    #1

    Hello Friends, I have a problem in redirect a page.i m using C#.net 2005 .i hv a dropdown list which is bind data from database Like State when i m selecting an item in dropdownlist then the corrospondin District should be come in the second dropdownlist. butit never comes.. there is a problem comes"The specified URL can not be found" I m writing the code below for beter understand. I m also set the Autopostback property =true in dropdownlist. protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { con.Open(); SqlCommand com = new SqlCommand("select State from StateInfo order by StateName asc", con); dr = com.ExecuteReader(); while (dr.Read() == true) { drp_regionname.Items.Add(dr[0].ToString()); } dr.Close(); } } protected void drp_regionname_SelectedIndexChanged(object sender, EventArgs e) { string RegionName = drp_regionname.SelectedValue.ToString(); SqlCommand com1 = new SqlCommand("select district from DistrictInfo where StateName ='" + RegionName + "'", con); con.Open(); dr = com1.ExecuteReader(); while (dr.Read()) { drp_unitname.Items.Add(dr[0].ToString()); } dr.Close(); con.Close(); } This code is running fine in local server but not running in Remote server.. Plz help me....... Thanks ...

    S V L 3 Replies Last reply
    0
    • P Parameswar Mal

      Hello Friends, I have a problem in redirect a page.i m using C#.net 2005 .i hv a dropdown list which is bind data from database Like State when i m selecting an item in dropdownlist then the corrospondin District should be come in the second dropdownlist. butit never comes.. there is a problem comes"The specified URL can not be found" I m writing the code below for beter understand. I m also set the Autopostback property =true in dropdownlist. protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { con.Open(); SqlCommand com = new SqlCommand("select State from StateInfo order by StateName asc", con); dr = com.ExecuteReader(); while (dr.Read() == true) { drp_regionname.Items.Add(dr[0].ToString()); } dr.Close(); } } protected void drp_regionname_SelectedIndexChanged(object sender, EventArgs e) { string RegionName = drp_regionname.SelectedValue.ToString(); SqlCommand com1 = new SqlCommand("select district from DistrictInfo where StateName ='" + RegionName + "'", con); con.Open(); dr = com1.ExecuteReader(); while (dr.Read()) { drp_unitname.Items.Add(dr[0].ToString()); } dr.Close(); con.Close(); } This code is running fine in local server but not running in Remote server.. Plz help me....... Thanks ...

      S Offline
      S Offline
      Sandeep Akhare
      wrote on last edited by
      #2

      Could explain where is the problem ? Where are you redirecting to another page ? drp_unitname drop down list is not getting populated with items ?

      Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

      1 Reply Last reply
      0
      • P Parameswar Mal

        Hello Friends, I have a problem in redirect a page.i m using C#.net 2005 .i hv a dropdown list which is bind data from database Like State when i m selecting an item in dropdownlist then the corrospondin District should be come in the second dropdownlist. butit never comes.. there is a problem comes"The specified URL can not be found" I m writing the code below for beter understand. I m also set the Autopostback property =true in dropdownlist. protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { con.Open(); SqlCommand com = new SqlCommand("select State from StateInfo order by StateName asc", con); dr = com.ExecuteReader(); while (dr.Read() == true) { drp_regionname.Items.Add(dr[0].ToString()); } dr.Close(); } } protected void drp_regionname_SelectedIndexChanged(object sender, EventArgs e) { string RegionName = drp_regionname.SelectedValue.ToString(); SqlCommand com1 = new SqlCommand("select district from DistrictInfo where StateName ='" + RegionName + "'", con); con.Open(); dr = com1.ExecuteReader(); while (dr.Read()) { drp_unitname.Items.Add(dr[0].ToString()); } dr.Close(); con.Close(); } This code is running fine in local server but not running in Remote server.. Plz help me....... Thanks ...

        V Offline
        V Offline
        vkrajeesh
        wrote on last edited by
        #3

        from ur code it seems u r not redirecting ur page anywhere. the same page is posted back. As far as the URL not found error , check the "REDIRECT" code u have written and see whether the target page u r specifying exists in ur website. could u post the conn string info as well as the redirect section of ur code. Regards, Rajeesh Did u know-Maths Illiteracy affects 9 out of 7 people

        1 Reply Last reply
        0
        • P Parameswar Mal

          Hello Friends, I have a problem in redirect a page.i m using C#.net 2005 .i hv a dropdown list which is bind data from database Like State when i m selecting an item in dropdownlist then the corrospondin District should be come in the second dropdownlist. butit never comes.. there is a problem comes"The specified URL can not be found" I m writing the code below for beter understand. I m also set the Autopostback property =true in dropdownlist. protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { con.Open(); SqlCommand com = new SqlCommand("select State from StateInfo order by StateName asc", con); dr = com.ExecuteReader(); while (dr.Read() == true) { drp_regionname.Items.Add(dr[0].ToString()); } dr.Close(); } } protected void drp_regionname_SelectedIndexChanged(object sender, EventArgs e) { string RegionName = drp_regionname.SelectedValue.ToString(); SqlCommand com1 = new SqlCommand("select district from DistrictInfo where StateName ='" + RegionName + "'", con); con.Open(); dr = com1.ExecuteReader(); while (dr.Read()) { drp_unitname.Items.Add(dr[0].ToString()); } dr.Close(); con.Close(); } This code is running fine in local server but not running in Remote server.. Plz help me....... Thanks ...

          L Offline
          L Offline
          l0kke
          wrote on last edited by
          #4

          Your code is filling drop down from database on PageLoad, if region name selection changes, it inserts additional data from the db (not clearing previous data from the drop down!, is it what you want?) I don't see any redirection at all! However, few tips: 1. in sqlcommand, always use Parameters instead of concatenated strings as a query, to prevent sql injection (security flaw): SqlCommand com1 = new SqlCommand("select district from DistrictInfo where StateName = @RegionName", con); com1.Parameters.Add(new SqlParameter("@RegionName", RegionName)); 2. be sure you are closing connection to database when you don't need it anymore 3. use 'using' clause when possible, to ensure your IDisposible objects are going to be disposed in all cases (no need to call dr.Close(), as it is going to be called in Dispose() method: using (dr = com1.ExecuteReader()) { while (dr.Read()) { drp_unitname.Items.Add(dr[0].ToString()); } } 4. use exception handling, try {...} catch {...} blocks, at least in event handlers

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups