title: Using Dropdownlist in a gridview Asp.Net?
body: <p>I want to use a dropdownlist on a gridview... I have the following code from asp.net</p>
  
  <pre><code>&lt;asp:GridView ID="grdvEventosVendedor" runat="server" AllowPaging="True" 
                  AutoGenerateColumns="False" CellPadding="4" DatakeyNames="idCita"
                  EmptyDataText="No Hay Eventos Para Este Vendedor" ForeColor="#333333" 
                  GridLines="None" AllowSorting="True"
                  onpageindexchanging="grdvEventosVendedor_PageIndexChanging" 
                  onrowcommand="grdvEventosVendedor_RowCommand" 
                  onsorting="grdvEventosVendedor_Sorting" CellSpacing="1" HorizontalAlign="Center"&gt;
                  &lt;AlternatingRowStyle BackColor="White" ForeColor="#284775"/&gt;
  
                  &lt;Columns&gt;
                      &lt;asp:TemplateField HeaderText="" ItemStyle-Width="35px"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:ImageButton ID="imgBtnEdicEvento" runat="server" 
                                  CommandArgument='&lt;%# Eval("idCita")%&gt;' CommandName="Edicion" 
                                  Height="32px" ImageUrl="~/img/pencil_32.png" Width="32px" /&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
  
                      &lt;asp:TemplateField HeaderText="" ItemStyle-Width="35px"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:ImageButton ID="imgBtnDelete" runat="server"
                                  CommandName="Borrar" 
                                  ImageUrl="~/img/1385_Disable_16x16_72.png" 
                                  onclientclick="return confirm('¿Desea eliminar el registro?');" 
                                  CommandArgument='&lt;%# Eval("idCita")%&gt;' /&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
  
                      &lt;asp:BoundField DataField="Cliente" HeaderText="Cliente" InsertVisible="False" ReadOnly="True" SortExpression="Cliente" ItemStyle-Width="50px" /&gt;
                      &lt;asp:BoundField DataField="Empresa" HeaderText="Empresa" InsertVisible="False" ReadOnly="True" SortExpression="Empresa" ItemStyle-Width="50px"/&gt;
                      &lt;asp:BoundField DataField="Telefono" HeaderText="Telefono" InsertVisible="False" ReadOnly="True" SortExpression="Telefono" ItemStyle-Width="50px"/&gt;
                      &lt;asp:BoundField DataField="Nextel" HeaderText="Nextel" InsertVisible="False" ReadOnly="True" SortExpression="Nextel" ItemStyle-Width="50px"/&gt;
                      &lt;asp:BoundField DataField="Tipo" HeaderText="Tipo" InsertVisible="False" ReadOnly="True" SortExpression="Tipo" ItemStyle-Width="50px"/&gt;
                      &lt;asp:BoundField DataField="Descripcion" HeaderText="Descripcion" InsertVisible="False" ReadOnly="True" SortExpression="Descripcion" ItemStyle-Width="100px"/&gt;
  
                      &lt;asp:TemplateField HeaderText="Fecha" SortExpression="Fecha" ItemStyle-Width="50px"&gt;
                          &lt;ItemTemplate&gt;                                            
                              &lt;%# DataBinder.Eval(Container.DataItem, "Fecha", "{0:dd/MM/yyyy}")%&gt;
                          &lt;/ItemTemplate&gt;
  
                          &lt;EditItemTemplate&gt;                                        
                              &lt;asp:TextBox ID="tbxFecha"  runat="server" Text='&lt;%#Bind("Fecha","{0:dd/MM/yyyy}") %&gt;' ValidationGroup="gpEdicionAgenda"&gt;
                              &lt;/asp:TextBox&gt;
                          &lt;/EditItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
  
                      &lt;asp:BoundField DataField="HoraInicio" HeaderText="Hora" InsertVisible="False" ReadOnly="True" SortExpression="HoraInicio" ItemStyle-Width="50px"/&gt;
                      &lt;asp:BoundField DataField="Lugar" HeaderText="Lugar" InsertVisible="False" ReadOnly="True" SortExpression="Lugar" ItemStyle-Width="50px"/&gt;
  
                      &lt;asp:TemplateField HeaderText="Estado" ItemStyle-Width="50px"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:DropDownList ID="dpdListEstatus" runat="server"&gt;
                                  &lt;asp:ListItem&gt;Pendiente&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem&gt;Atendido&lt;/asp:ListItem&gt;
                              &lt;/asp:DropDownList&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
  
                      &lt;asp:TemplateField HeaderText="CRM" ItemStyle-Width="25px"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:ImageButton ID="imgBtnCRM" runat="server"
                                  CommandArgument='&lt;%# Eval("IdCliente")%&gt;' CommandName="CRM" 
                                  ImageUrl="~/img/activar.png" Width="16px" Height="16px" /&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
  
                      &lt;asp:TemplateField HeaderText="VM" ItemStyle-Width="25px"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:ImageButton ID="imgBtnVerMas" runat="server"
                                  CommandArgument='&lt;%# Eval("IdCliente")%&gt;' CommandName="VerMas" 
                                  ImageUrl="~/img/search.png" Width="16px" Height="16px" /&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                  &lt;/Columns&gt;
  
                  &lt;EditRowStyle BackColor="#999999" Font-Size="Small" /&gt;
                  &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                  &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" Font-Size="Larger" /&gt;
                  &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt;
                  &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" Font-Size="Small" /&gt;
                  &lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /&gt;
                  &lt;SortedAscendingCellStyle BackColor="#E9E7E2" /&gt;
                  &lt;SortedAscendingHeaderStyle BackColor="#506C8C" /&gt;
                  &lt;SortedDescendingCellStyle BackColor="#FFFDF8" /&gt;
                  &lt;SortedDescendingHeaderStyle BackColor="#6F8DAE" /&gt;
              &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>The part where it says  is the part where I want the ddl to be...</p>
  
  <p>You'll might've also noticed that I use a total of 4 buttons for edit, delete, etc...
  However I guess that's another story...</p>
  
  <p>I want it to do a couple of things... first of, you'll notice that I have the dropdownlist with 2 values... that's because I get a datasource from a query, and those are the 2 possible values that this column can get...</p>
  
  <p>So #1 should be... how can I make that the Ddl's Selected Value is the one I get from the query....</p>
  
  <p>and #2 I can manually change the value of the ddl, so I want it to make a postback and update that specific row with the new value (the reason I need the postback would be so I can trigger for example a ddl ONSELECTEDINDEX CHANGED and therefore use the cs file to create a new query, update the row, and then refresh the gridview again)</p>
  
  <p>I suppose that all of this might have something to do with rowcommand, just like the way the other 4 buttons work.</p>
  
  <p>I'm using C# on this, so It would be helpful if you can help me using C# if you're method involves the cs file...</p>
  
  <p>Thanks</p>