please anybody to help Dropdownlist selected index problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: please anybody to help Dropdownlist selected index problem

  1. #1
    Join Date
    Dec 2006
    Posts
    13

    please anybody to help Dropdownlist selected index problem

    Hi

    I am working in asp.net with C# web application, I have used visual studio 2003, i have used dropdownlist
    in my application to populate the data from mysql database, i have got problem while i selected the item from
    dropdownlist, its not selecting correct item i'm selecting from dropdownlist, i have 64 records in my table, but i
    tried to work with upto 15 records it will not giving problem, when the scroll will enable to dropdownlist its
    giving problem, its not selecting the correct record what i'm selecting in dropdownlist, i have used following
    codes to fill dropdown and selected index,

    public DataSet LoadShotTaskCode()
    {
    cmd = new MySqlCommand("HD_PROC_LOADSHOTTASK",global_con);
    cmd.CommandType = CommandType.StoredProcedure;
    adapter = new MySqlDataAdapter(cmd);
    dataset = new DataSet();
    adapter.Fill(dataset,"hd_tbl_taskcodes");
    return dataset;
    }

    private void FillDropDown()
    {
    Access = new clshome();
    ds = Access.LoadShotTaskCode();
    if(ds.Tables[0].Rows.Count != 0 )
    {
    DropDownList1.DataTextField = "task_code";
    DropDownList1.DataValueField = "task_description";
    DropDownList1.DataSource = ds;
    DropDownList1.DataBind();
    if(DropDownList1.Items.Count != 0)
    {
    TxtEditTaskCode.Text = ds.Tables[0].Rows[0]["task_code"].ToString();
    TxtEditTaskDesc.Text = ds.Tables[0].Rows[0]["task_description"].ToString();
    }
    }
    else
    {
    DropDownList1.Items.Clear();
    }
    }

    public MySqlDataReader Select_ShotTaskCoes(string tcode)
    {
    MySqlCommand taskcmd = new MySqlCommand("select * from hd_tbl_taskcodes where task_code='"+ tcode+"'",global_con);
    global_con.Open();
    MySqlDataReader dr = taskcmd.ExecuteReader(CommandBehavior.CloseConnection);
    return dr;
    }

    private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    Access = new clshome();
    MySqlDataReader taskdr = Access.Select_ShotTaskCoes(DropDownList1.SelectedItem.Text);
    if(taskdr.Read())
    {
    TxtEditTaskCode.Text = taskdr.GetValue(0).ToString();
    TxtEditTaskDesc.Text = taskdr.GetValue(1).ToString();
    }
    Access.global_con.Close();
    }


    please anybody help me to slove this problem, advanced Thanks for any reply.

    Thanks.

  2. #2
    Join Date
    May 2006
    Posts
    64

Similar Threads

  1. DropDownList Selected Item
    By Scott S. in forum ASP.NET
    Replies: 1
    Last Post: 03-15-2007, 01:58 AM
  2. Replies: 1
    Last Post: 02-07-2007, 05:32 PM
  3. dropdownlist values problem
    By jabbarsb in forum ASP.NET
    Replies: 1
    Last Post: 01-17-2007, 10:40 AM
  4. .Net 2 C#: DropDownList arguments and me
    By Tomzen in forum ASP.NET
    Replies: 1
    Last Post: 12-18-2006, 10:47 AM
  5. Reliability Problem
    By elise in forum Java
    Replies: 0
    Last Post: 10-30-2002, 04:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center