-1
我试图做这个编辑页面,当用户想编辑一个案例时,它得到案例id,并将用户带到另一个表单,用户只能编辑所选案例ID的信息。 其中一个信息称为代理,其中已选择代理。例如,这种情况下,id = 20包含具有agent20的代理信息。在这个编辑页面中,我尝试了一个组合框,其中agent20已经在page_onload中作为组合框中的默认值选中,但组合框已经包含代理1至20之类的代理的其余部分。请注意,这是一个窗口形式,而不是一个asp.net的asp.net可以使用FindByValue的代码....ComboBox selectedValue/Item
SqlDataAdapter ad4 = new SqlDataAdapter();
SqlCommand command4 = new SqlCommand();
DataSet ds4 = new DataSet();
ds4.Clear();
SqlConnection connection4 = new SqlConnection();
String sqlText4 = "SELECT * FROM [Agent] WHERE TypeID = 1";
connection4.ConnectionString = "-connectionstring-";
command4.Connection = connection4;
command4.CommandText = sqlText4;
ad4.SelectCommand = command4;
connection4.Open();
ad4.Fill(ds4, "data");
connection4.Close();
comboBox1.DataSource = ds4.Tables["data"];
//comboBox1.SelectionStart = agentnumber;
//comboBox1.GetItemText(agentnumber);
comboBox1.DisplayMember = "AgentName";
comboBox1.ValueMember = "AgentID";
你的实际需求是什么,你想通过价值,或者你想设置组合的特殊价值,并请各位请不要简单地冷静下来,让他有机会清除自己 – sajanyamaha