Adding a new Row to a DataView

Results 1 to 2 of 2

Thread: Adding a new Row to a DataView

  1. #1
    Join Date
    Dec 1969

    Default Adding a new Row to a DataView

    Hi,<BR><BR>I am filling a DropDownList with SQL data (key & value pairs) via a DataView. I need to be able to add another (a default of "-1" and "-- None --") row in the DDL and Id like to do this in the DataView (simply because this DataView is generated and returned from a static class and I want to keep my code as neat as possible). Any ideas how I could do this? <BR><BR>Column names are &#039;GenreId&#039; and &#039;Genre&#039;. Here is the code I&#039;ve written in my static class to fill the DataView:<BR><BR>public static DataView GetGenreDataView()<BR>{<BR> DataView DV;<BR> SqlDataAdapter DataAd;<BR> SqlConnection Conn = GetConnection();<BR> DataSet DataS = new DataSet();<BR> DataAd = new SqlDataAdapter("pGetAllGenres", Conn);<BR> DataAd.SelectCommand.CommandType = CommandType.StoredProcedure;<BR> DataAd.Fill(DataS,"TempInfo");<BR> DV = new DataView(DataS.Tables["TempInfo"]);<BR> Conn.Close();<BR> return DV;<BR>}<BR><BR>This has been driving me slowly crazy! Any help much appreciated.<BR><BR>Thanks<BR>Bill

  2. #2
    Join Date
    Dec 1969

    Default RE: Adding a new Row to a DataView

    It is easy to add rows to a DataTable but you cannot do the same to a DataView.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts