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 is dynamic dropdown list control ...Please help!!!

problem is dynamic dropdown list control ...Please help!!!

Scheduled Pinned Locked Moved ASP.NET
databasehelpcsharpasp-netgraphics
3 Posts 2 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.
  • S Offline
    S Offline
    skhan17
    wrote on last edited by
    #1

    Hello, I want submit button to fetch different query results from the database. So I have implemented which query to execute inside the SubmitButton_Click function/method. But it's not working as I have desired....it's fetching one query every time. To give you a brief idea, in my .aspx I have 2 dropdown lists (1 to select which query to run and another one to select which patient number should I pull from the DB), 1 text box which contains date field. I have kinda found what's causing the problem....but don't know how to solve it. Somehow from the drop down list "ANY" is selected all the times.....no matter what I select from the second dropdown list. Any suggestion would be really helpful. The code is as follows:

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Configuration;
    using System.Data;
    using System.Data.OleDb;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Xml;

    namespace HIV
    {
    /// <summary>
    /// Summary description for run_specific_query.
    /// </summary>
    public class run_specific_query : System.Web.UI.Page
    {
    protected HIV.Controls.NavMenu navMenu;
    protected HIV.Controls.NavSubMenu navSubMenu;
    protected System.Web.UI.HtmlControls.HtmlGenericControl message;
    protected System.Web.UI.WebControls.Label resultsLabel;
    protected System.Web.UI.WebControls.DropDownList Specific_Query_DDL;
    protected System.Web.UI.WebControls.DropDownList mlno_DDL;
    protected System.Web.UI.WebControls.TextBox date_TB;
    protected System.Web.UI.WebControls.CompareValidator dateValidator;
    protected System.Web.UI.WebControls.DataGrid resultsDatagrid;
    protected System.Web.UI.WebControls.Button submitButton;
    protected System.Web.UI.WebControls.Label data_src;
    protected System.Web.UI.WebControls.LinkButton exportLinkbutton;

    private void Page_Load(object sender, System.EventArgs e)
    {
    navMenu.SelectedMainItem = HIV.Controls.NavMenu.MainItems.QUERY;
    navSubMenu.SelectedMainItem = HIV.Controls.NavMenu.MainItems.QUERY;
    navSubMenu.SelectedSubItem = HIV.Controls.NavSubMenu.SubItems.RUN_SPECIFIC_QUER Y;

    getMLNO();

    //if (!this.IsPostBack)
    //LoadQueryLinks();
    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    BuildQueryForm(); [This function/method is calling the submit button function

    D 1 Reply Last reply
    0
    • S skhan17

      Hello, I want submit button to fetch different query results from the database. So I have implemented which query to execute inside the SubmitButton_Click function/method. But it's not working as I have desired....it's fetching one query every time. To give you a brief idea, in my .aspx I have 2 dropdown lists (1 to select which query to run and another one to select which patient number should I pull from the DB), 1 text box which contains date field. I have kinda found what's causing the problem....but don't know how to solve it. Somehow from the drop down list "ANY" is selected all the times.....no matter what I select from the second dropdown list. Any suggestion would be really helpful. The code is as follows:

      using System;
      using System.Collections;
      using System.ComponentModel;
      using System.Configuration;
      using System.Data;
      using System.Data.OleDb;
      using System.Drawing;
      using System.Web;
      using System.Web.SessionState;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using System.Web.UI.HtmlControls;
      using System.IO;
      using System.Xml;

      namespace HIV
      {
      /// <summary>
      /// Summary description for run_specific_query.
      /// </summary>
      public class run_specific_query : System.Web.UI.Page
      {
      protected HIV.Controls.NavMenu navMenu;
      protected HIV.Controls.NavSubMenu navSubMenu;
      protected System.Web.UI.HtmlControls.HtmlGenericControl message;
      protected System.Web.UI.WebControls.Label resultsLabel;
      protected System.Web.UI.WebControls.DropDownList Specific_Query_DDL;
      protected System.Web.UI.WebControls.DropDownList mlno_DDL;
      protected System.Web.UI.WebControls.TextBox date_TB;
      protected System.Web.UI.WebControls.CompareValidator dateValidator;
      protected System.Web.UI.WebControls.DataGrid resultsDatagrid;
      protected System.Web.UI.WebControls.Button submitButton;
      protected System.Web.UI.WebControls.Label data_src;
      protected System.Web.UI.WebControls.LinkButton exportLinkbutton;

      private void Page_Load(object sender, System.EventArgs e)
      {
      navMenu.SelectedMainItem = HIV.Controls.NavMenu.MainItems.QUERY;
      navSubMenu.SelectedMainItem = HIV.Controls.NavMenu.MainItems.QUERY;
      navSubMenu.SelectedSubItem = HIV.Controls.NavSubMenu.SubItems.RUN_SPECIFIC_QUER Y;

      getMLNO();

      //if (!this.IsPostBack)
      //LoadQueryLinks();
      }

      #region Web Form Designer generated code
      override protected void OnInit(EventArgs e)
      {
      //
      // CODEGEN: This call is required by the ASP.NET Web Form Designer.
      //
      BuildQueryForm(); [This function/method is calling the submit button function

      D Offline
      D Offline
      droth17
      wrote on last edited by
      #2

      I'm not a C# guy, but it sure seems like you call getMLNO on every page_load which then adds in the "Any" item into the dropdownlist which overrides what the user selected. Put that in a If Not Ispostback then (C# equivalent for you) you should be all set.

      S 1 Reply Last reply
      0
      • D droth17

        I'm not a C# guy, but it sure seems like you call getMLNO on every page_load which then adds in the "Any" item into the dropdownlist which overrides what the user selected. Put that in a If Not Ispostback then (C# equivalent for you) you should be all set.

        S Offline
        S Offline
        skhan17
        wrote on last edited by
        #3

        I don't know how to thank you enough! :)all these times I am wondering why this is happening!! But I understood that something is wrong with the post back condition and the way I am calling getMLNO() cause every time I refresh the page or hit submit the MLNO dropdown list was getting refreshed as well and thus selecting ANY every time....

        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