locked
working with xsd RRS feed

  • Question

  • User1594725402 posted

    Hi,

      i'm using dataset (tableAdapter, datatable) to fill my dropdownlist.  now i want to add a row on the TOP of the list. 

    TableAdapters.Clothes c = new TableAdapters.Clothes();

    DataSet.DataTable Cdt = c.GetData(); //up to here everything works

    then when i add new row, it goes at the bottom of the list, but i want it on top of the list:

     c.Rows.Add("Please_Select_a_Value"); // this line should display before the list



    Wednesday, February 8, 2012 12:49 AM

Answers

  • User3866881 posted

    Hello YashaJan:)

    If cdt is a DataTable,Just use Insert instead:

    See:

    DataSet.DataTable Cdt = c.GetData();
    DataRow row = Cdt.NewRow();
    Cdt.Rows.InsertAt(row,0);
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 9, 2012 8:57 PM

All replies

  • User-963541686 posted

    then move this code before the GetData() method. so the first item will be the please_Select_a_value

     

    TableAdapters.Clothes c = new TableAdapters.Clothes();
    c.Rows.Add("Please_Select_a_Value");
    DataSet.DataTable Cdt = c.GetData();

     

    Wednesday, February 8, 2012 5:09 AM
  • User1594725402 posted

    Sorry my mistype,

      the code is:

      DataSet.DataTable Cdt = c.GetData();

        Cdt.Rows.Add("Please_Select_a_Value");

    and i want to add this row Cdt.Rows.Add("Please_Select_a_Value"); on the top.

    Wednesday, February 8, 2012 11:50 AM
  • User3866881 posted

    Hello YashaJan:)

    If cdt is a DataTable,Just use Insert instead:

    See:

    DataSet.DataTable Cdt = c.GetData();
    DataRow row = Cdt.NewRow();
    Cdt.Rows.InsertAt(row,0);
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 9, 2012 8:57 PM