However, there is an item "All Messages" that is to be added so that when a user selects "All Messages" from the DropDown List, it will displays all the items along with their information in datagrid.
But if user selects a single item, all that item and its information will be reflected in the datagrid.
My problem, is how can I make "All Messages" appear first in the dropdown list so that the user sees only "All Messages" in the Dropdown list when he views the datagrid and then can select a particular item of his choice later on.
The code I have written is :
SqlConnection
conn = new SqlConnection(ConnectionString); SqlDataAdapter additemsda = new SqlDataAdapter("select Newsletter_Topic from Admin_Add_Newsletter_Topic", conn);conn.Open();
DataSet additemsds = new DataSet();additemsda.Fill(additemsds,
"Admin_Add_Newsletter_Topic"); DataTable additemsdt = new DataTable();additemsdt = additemsds.Tables[
"Admin_Add_Newsletter_Topic"]; DataRow[] additemsdr = new DataRow[additemsdt.Rows.Count];additemsdr = additemsdt.Select();
ArrayList Article = new ArrayList(); if (additemsdr.Length != 0){
Article_Grp = additemsdr[0][
"Newsletter_Topic"].ToString(); for (int i = 0; i < additemsdr.Length; i++){
Article.Add(additemsdr[i][
"Newsletter_Topic"].ToString());}
ddlType.DataSource = Article;
ddlType.DataBind();
ddlType.Items.Add(
"All Messages");}
conn.Close();
Please help
Sandhya BhosalePosted Oct 31, 2006, 12:23 AM
Mahesh ChandPosted Oct 28, 2006, 3:42 PM
Try InsertAt(0, "All Messages") method after data is loaded or add "All Messsages" to your data soruce (DataSet or DataTable) dynamically.