468,771 Members | 1,930 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

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.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);
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.
Mar 7 '07 #1
2 1336
radcaesar
759 Expert 512MB
Not selecting correct value means ?

What value you get when make select change in combo ?

:)
Mar 7 '07 #2
nmsreddi
366 256MB
Hello

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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.