Hi,<BR><BR>How is it possible for two DropDownLists to be databound to identical DataTables yet display them differently?<BR><BR>I used VB.NET to create a DataTable (containing a list of names) from an Access DB, and display this DataTable via a DropDownList. Then I inserted a new row at position 0 into the DataTable, so that the initially displayed value would be "SELECT A NAME".<BR><BR>So far, so good.<BR><BR>Then, having learning something about creating custom objects, I created my own "Database" object, with two methods, one to create DataTables, and another to insert rows into those DataTables at the specified position. I used this custom object to pull the data out of Access, put it in a DataTable, insert a new row at position 0, and display the DataTable via a DropDownList.<BR><BR>Now, the problem.<BR><BR>The trouble is, when I did everything using my custom object, although EXACTLY THE SAME DataTable is created as first time round, it does NOT display the same way! The added row "SELECT A NAME" is displayed at the BOTTOM of the DropDownList, instead of being the first item (which is what I want).<BR><BR>I can&#039;t understand why this is happening. <BR><BR>I even went to the trouble of iterating through both DataTables (one created with the custom object, one normally) and displaying the contents on the screen so I could visually check that the content of both DataTables is identical.<BR><BR>Can anyone tell me what&#039;s going on here? Maybe it&#039;s something really simple....<BR><BR>Thanks,<BR><BR>JON<BR><BR>______ __________________________________________________ _______________________<BR><BR><BR><BR>+++++++++++ ++++++++++<BR>MainPage.aspx<BR>+++++++++++++++++++ ++<BR><BR><BR>&#060;%@ Page Language="VB" Debug="true" Trace="false" %&#062;<BR>&#060;%@ Import Namespace="System.Data" %&#062;<BR>&#060;%@ Import Namespace="System.Data.OleDb" %&#062;<BR><BR>&#060;script runat="server"&#062;<BR>sub Page_Load(obj as object, e as eventargs)<BR><BR>&#039;*** Set variables for my custom object (code in file Database.vb) <BR>dim objDatabase as new BusinessObjects.Database<BR>objDatabase.Connection String = ConfigurationSettings.AppSettings("ConnectionStrin g")<BR>Dim ds as new DataSet()<BR>objDataBase.DataSet = ds<BR><BR>&#039;*** Create DataTable via custom object method<BR>DDL1.DataSource = objDatabase.CreateDataTableDefaultView("ExampleDat aTable", "SELECT tblPeople.PersonID, tblPeople.LastName FROM tblPeople;")<BR><BR>&#039;*** insert row at position 0 into DataTable via custom object method<BR>objDatabase.InsertIntoDataTable("Example DataTable", 0, "PersonID", -1, "LastName", "SELECT A NAME")<BR><BR>&#039;*** Bind DDL1 to this DataTable<BR>DDL1.DataTextField = "LastName"<BR>DDL1.DataValueField = "PersonID"<BR>DDL1.DataBind()<BR><BR><BR><BR>&#039 ;*** Create a DataTable via normal VB.NET (no custom object)<BR>Dim objConn as New OleDbConnection ( ConfigurationSettings.AppSettings("ConnectionStrin g") )<BR>Dim objAdapter as New OleDbDataAdapter ( "SELECT tblPeople.PersonID, tblPeople.LastName FROM tblPeople;", objConn )<BR>objAdapter.Fill(ds, "ExampleDataTable2")<BR><BR>&#039;*** insert row at position 0 into DataTable via normal VB.NET<BR>Dim DefaultItemParentDataRow as DataRow = ds.Tables("ExampleDataTable2").NewRow()<BR>Default ItemParentDataRow("PersonID") = -1<BR>DefaultItemParentDataRow("LastName") = "SELECT A NAME"<BR>ds.Tables("ExampleDataTable2").Rows.Inser tAt(DefaultItemParentDataRow, 0)<BR><BR>&#039;*** Bind DDL2 to this second DataTable<BR>DDL2.DataSource = ds.Tables("ExampleDataTable2")<BR>DDL2.DataTextFie ld = "LastName"<BR>DDL2.DataValueField = "PersonID"<BR>DDL2.DataBind()<BR><BR>&#039;*** Iterate through and display content of both DataTables to prove they are identical <BR>Dim myRow as DataRow<BR>For each myRow in ds.Tables("ExampleDataTable").Rows<BR> Response.Write("Person ID: " & myRow.Item("PersonID") & " and LastName is " & myRow.Item("LastName") & "<BR>")<BR>next myRow<BR><BR>Response.Write("&#060;hr&#062;")<BR>< BR>For each myRow in ds.Tables("ExampleDataTable2").Rows<BR> Response.Write("Person ID: " & myRow.Item("PersonID") & " and LastName is " & myRow.Item("LastName") & "<BR>")<BR>next myRow<BR><BR><BR>end sub <BR><BR>&#060;/script&#062;<BR><BR>&#060;html&#062;&#060;body&#06 2;<BR><BR>&#060;form runat="server"&#062;<BR>DDL1 - populated via custom object objDatabase ("SELECT A NAME" displays at END of DDL):<BR><BR><BR>&#060;asp:DropDownList runat="server" id="DDL1" /&#062;<BR>&#060;hr&#062;<BR>DDL2 - populated via normal vb.net code ("SELECT A NAME" displays at BEGINNING of DDL):<BR><BR><BR>&#060;asp:DropDownList runat="server" id="DDL2" /&#062;<BR>&#060;/form&#062;<BR><BR>&#060;/body&#062;&#060;/html&#062;<BR><BR><BR><BR><BR>++++++++++++++++++++ +++++++++++++<BR>Database.vb<BR>++++++++++++++++++ +++++++++++++++<BR><BR><BR>Imports System<BR>Imports System.Data<BR>Imports System.Data.OleDb<BR>Imports System.Collections<BR><BR>Namespace BusinessObjects<BR><BR> Public Class Database<BR> public ConnectionString as String<BR> public DataSet as DataSet<BR> private objConn as OleDbConnection<BR> private objCmd as OleDbCommand<BR> private objAdapter as OleDbDataAdapter<BR> <BR> <BR> public function CreateDataTableDefaultView(DataTableName as String, strQuery as string) as DataView<BR> try<BR> objConn = new OleDbConnection(ConnectionString)<BR> objAdapter = New OleDbDataAdapter(strQuery, objConn)<BR> objAdapter.Fill(DataSet, DataTableName)<BR> return DataSet.Tables(DataTableName).DefaultView<BR> catch ex as OleDbException<BR> return nothing<BR> end try<BR> end function<BR> <BR> <BR> <BR> public function InsertIntoDataTable(DataTableName as String, insertAt as Integer, FirstColumnName as String, FirstColumnValue as Integer, SecondColumnName as String, SecondColumnValue as String)<BR> Dim myDataRow as DataRow = DataSet.Tables(DataTableName).NewRow()<BR> myDataRow(FirstColumnName) = FirstColumnValue<BR> myDataRow(SecondColumnName) = SecondColumnValue<BR> DataSet.Tables(DataTableName).Rows.InsertAt(myData Row, insertAt) <BR> End function<BR> <BR> <BR> End Class<BR><BR>End Namespace<BR><BR><BR><BR>