title: How do I set a DataSource to a DropDownList?
body: <p>I read some of the others threads and didnt work out for me  =\
  I have a <code>GridView</code> with a <code>DropDownList</code> in one field. I'd like to know How may I set a <code>DataSource</code> for that ? I'm not using Templates neither ItemTemplate or EditItemTemplate I don't know how it work exactly  , so i'm not using it yet.</p>
  
  <p>So far I have only created the GridView And filled the fields with data but I don't know how to do the same for the <code>DropDownList</code>. SOmething is missing I guess, it is giving me an error (<code>"The Reference of the Object was not set as an instance of an object"</code>)</p>
  
  <pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
          {                                
              DropDownList Drop_Prioridades = (DropDownList)e.Row.FindControl("Drop_Prioridades");
              Drop_Prioridades.DataTextField = "BAIXA";
              Drop_Prioridades.DataValueField = "1";
              Drop_Prioridades.DataTextField = "MEDIA";
              Drop_Prioridades.DataValueField = "2";
              Drop_Prioridades.DataTextField = "ALTA";
              Drop_Prioridades.DataValueField = "3";
              Drop_Prioridades.DataBind();
          }
  </code></pre>
  
  <p>I Also tried this / Same error =\</p>
  
  <pre><code>DataSet ds = func.LoadPriority();
  
              foreach (DataRow row in ds.Tables[0].Rows)
              {
                  ListItem item = new ListItem();
                  item.Text = row["prioridade"].ToString();
                  item.Value = row["id"].ToString();
                  DropDownList ddlPrioridades = (DropDownList)e.Row.FindControl("Drop_Prioridades");
                  ddlPrioridades.Items.Add(item);
              }
  </code></pre>
  
  <p>And Tried this too...</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;columns&gt;                    
  
       &lt;asp:TemplateField HeaderText="PRIORIDADE" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="100px"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:DropDownList ID="Drop_Prioridades" Width="120px" runat="server" &gt;&lt;/asp:DropDownList&gt; 
  &lt;/ItemTemplate&gt;                    
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>Code Behind:</p>
  
  <pre><code> DataSet ds = func.CarregaPrioridade();
              DropDownList ddlist = (DropDownList)e.Row.FindControl("Drop_Prioridades");
              ddlist.DataSource = ds;
              ddlist.DataTextField = "prioridade";
              ddlist.DataValueField = "id";
  </code></pre>