title: How sort data taking from database in C#
body: <p>There is state table that have statename and circode but they are not sorted in table.
  I use <code>OrderByAsc("StateName")</code> where StateName is a column name of state table. How I get sorted state in dropdownlist. I use subsonic to fetch data from database.</p>
  
  <pre><code>StateCollection stc = (new 
  StateController()).getInstance().WFetchAll(true);
  
  
      ddlState.Items.Clear();
      if(addAllStates)
          ddlState.Items.Add(new ListItem("All States", "0"));
  
      //ddlState.DataSource = State.FetchAll();
      //ddlState.DataTextField = State.Columns.StateName;
      //ddlState.DataValueField = State.Columns.CircleCode;
      //ddlState.DataBind();
      stc = stc.OrderByAsc("CircleCode");
      stc.SaveAll();
      foreach (State st in stc)
      {
          ddlState.Items.Add(new ListItem(st.CircleCode + "-" + st.StateName, st.CircleCode));
      }
  </code></pre>