Hi
I am using a table to fill a dropdown box. The contents of the dropdown
box are ordered by a seq_no. I edit the seq_no and want to refresh the
dropdown box and show the new order. I can edit the table but the
changes to the seq_no is not changing the order of the dropdown box
when it is refreshed. Can anyone give me ideas on how to fix this?
Below is the code that I'm using.
//edit Question_Seq_No for record that is moved up
string sqlQuestionTempEditUP="UPDATE QuestionTemp SET Question_Seq_No =
'"+valSeqNum +"' " +
"WHERE Question_ID = "+valQuestionIDUp+" ";
SqlCommand sqlStatusCmdUP = new
SqlCommand(sqlQuestionTempEditUP,sqlConnection1);
sqlStatusCmdUP.CommandType = CommandType.Text;
daQuestionTemp.UpdateCommand =sqlStatusCmdUP;
sqlConnection1.Open();
rowcountUP=sqlStatusCmdUP.ExecuteNonQuery();
sqlConnection1.Close();
//Get the BTForm_Number
string sqlBTFormFind="SELECT * " +
"FROM BTForm " +
"WHERE BTForm_Status = 'Active' And ( BTForm_ID = "+valFormID+" )" ;
//sqlConnection1.Open();
SqlDataAdapter daBTFormFind=new SqlDataAdapter(sqlBTFormFind,
sqlConnection1);
dsMain1.BTForm.Clear();
daBTFormFind.Fill(dsMain1.BTForm);
DataTable dtBTForm = dsMain1.Tables["BTForm"];
DataRow BTFormRow;
BTFormRow = dtBTForm.Rows[0];
valBTFormNumberFind = (int)BTFormRow["BTForm_Number"];
drpQuestion.Items.Clear();
//Refresh the Question dropdown box
string sqlQuestionEdit="SELECT * " +
"FROM QuestionTemp " +
"WHERE (Question_Status = 'Active') And ( BTForm_Number =
"+valBTFormNumberFind+")" +
"Order By Question_Seq_No";
SqlDataAdapter daQuestionEdit=new SqlDataAdapter(sqlQuestionEdit,
sqlConnection1);
dsMain1.QuestionTemp.Clear();
daQuestionEdit.Fill(dsMain1.QuestionTemp);
DataTable questionDT = dsMain1.Tables["QuestionTemp"];
//fills the drpSelectQuestion
foreach (DataRow questionRow in questionDT.Rows)
{
ListItem newquestion= new ListItem();
newquestion.Text=questionRow["Question_Content"].ToString().Trim();
newquestion.Value=questionRow["Question_ID"].ToString().Trim();
drpQuestion.Items.Add(newquestion);
} //end foreach loop