471,114 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,114 software developers and data experts.

please anybody to help Dropdownlist selected index problem


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

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

private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
Access = new clshome();
MySqlDataReader taskdr = Access.Select_ShotTaskCoes(DropDownList1.SelectedI tem.Text);
TxtEditTaskCode.Text = taskdr.GetValue(0).ToString();
TxtEditTaskDesc.Text = taskdr.GetValue(1).ToString();

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

Mar 7 '07 #1
2 1397
759 Expert 512MB
Not selecting correct value means ?

What value you get when make select change in combo ?

Mar 7 '07 #2
366 256MB

what actuaaly your problem ,what happenning when select a value ,by default

is it going to first value in the list, are you using auto post back property of the

combobox to true, some times in page postback the values of the combo box

will not point to the value you have selected instead it goes to to the first value

in the list ,are you facing the same problem i think.

actually the problem you specified is unable to understand your requirement

please try to post with exact requirement
Mar 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Robin Bonin | last post: by
4 posts views Thread by wolfgang wagner | last post: by
1 post views Thread by clickon | last post: by
3 posts views Thread by Robert Dufour | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.