Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8378235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:53:04+00:00 2026-06-09T15:53:04+00:00

recently I asked a similar question, which you can find in the link below

  • 0

recently I asked a similar question, which you can find in the link below

Using Dropdownlist in a gridview Asp.Net?

I have a gridview that looks like this…

<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" 
                onrowdatabound="grdvEventosVendedor_RowDataBound" >
                <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>

                <Columns>
                    <asp:TemplateField HeaderText="" ItemStyle-Width="35px">
                        <ItemTemplate>
                            <asp:ImageButton ID="imgBtnEdicEvento" runat="server" 
                                CommandArgument='<%# Eval("idCita")%>' CommandName="Edicion" 
                                Height="32px" ImageUrl="~/img/pencil_32.png" Width="32px" />
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="" ItemStyle-Width="35px">
                        <ItemTemplate>
                            <asp:ImageButton ID="imgBtnDelete" runat="server"
                                CommandName="Borrar" 
                                ImageUrl="~/img/1385_Disable_16x16_72.png" 
                                onclientclick="return confirm('¿Desea eliminar el registro?');" 
                                CommandArgument='<%# Eval("idCita")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:BoundField DataField="Cliente" HeaderText="Cliente" InsertVisible="False" ReadOnly="True" SortExpression="Cliente" ItemStyle-Width="50px" />
                    <asp:BoundField DataField="Empresa" HeaderText="Empresa" InsertVisible="False" ReadOnly="True" SortExpression="Empresa" ItemStyle-Width="50px"/>
                    <asp:BoundField DataField="Telefono" HeaderText="Telefono" InsertVisible="False" ReadOnly="True" SortExpression="Telefono" ItemStyle-Width="50px"/>
                    <asp:BoundField DataField="Nextel" HeaderText="Nextel" InsertVisible="False" ReadOnly="True" SortExpression="Nextel" ItemStyle-Width="50px"/>
                    <asp:BoundField DataField="Tipo" HeaderText="Tipo" InsertVisible="False" ReadOnly="True" SortExpression="Tipo" ItemStyle-Width="50px"/>
                    <asp:BoundField DataField="Descripcion" HeaderText="Descripcion" InsertVisible="False" ReadOnly="True" SortExpression="Descripcion" ItemStyle-Width="100px"/>

                    <asp:TemplateField HeaderText="Fecha" SortExpression="Fecha" ItemStyle-Width="50px">
                        <ItemTemplate>                                            
                            <%# DataBinder.Eval(Container.DataItem, "Fecha", "{0:dd/MM/yyyy}")%>
                        </ItemTemplate>

                        <EditItemTemplate>                                        
                            <asp:TextBox ID="tbxFecha"  runat="server" Text='<%#Bind("Fecha","{0:dd/MM/yyyy}") %>' ValidationGroup="gpEdicionAgenda">
                            </asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>

                    <asp:BoundField DataField="HoraInicio" HeaderText="Hora" InsertVisible="False" ReadOnly="True" SortExpression="HoraInicio" ItemStyle-Width="50px"/>
                    <asp:BoundField DataField="Lugar" HeaderText="Lugar" InsertVisible="False" ReadOnly="True" SortExpression="Lugar" ItemStyle-Width="50px"/>
                    <%--<asp:BoundField DataField="Estado" HeaderText="Estado" InsertVisible="False" ReadOnly="True" SortExpression="Estado" ItemStyle-Width="50px"/>--%>

                    <asp:TemplateField HeaderText="Estado" ItemStyle-Width="50px">
                        <ItemTemplate>
                            <asp:DropDownList ID="dpdListEstado" runat="server" OnSelectedIndexChanged="dpdListEstado_SelectedIndexChanged" AutoPostBack="True">
                                <asp:ListItem>Pendiente</asp:ListItem>
                                <asp:ListItem>Atendido</asp:ListItem>
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="CRM" ItemStyle-Width="25px">
                        <ItemTemplate>
                            <asp:ImageButton ID="imgBtnCRM" runat="server"
                                CommandArgument='<%# Eval("IdCliente")%>' CommandName="CRM" 
                                ImageUrl="~/img/activar.png" Width="16px" Height="16px" />
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="VM" ItemStyle-Width="25px">
                        <ItemTemplate>
                            <asp:ImageButton ID="imgBtnVerMas" runat="server"
                                CommandArgument='<%# Eval("IdCliente")%>' CommandName="VerMas" 
                                ImageUrl="~/img/search.png" Width="16px" Height="16px" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>

                <EditRowStyle BackColor="#999999" Font-Size="Small" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" Font-Size="Larger" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" Font-Size="Small" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
            </asp:GridView>

As mentioned in the link, I had to manually add some code, like OnSelectedIndexChanged=”dpdListEstado_SelectedIndexChanged” AutoPostBack=”True” and also add this on the cs file…

    protected void dpdListEstado_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

I have tried it and it did work, whenever I change the value of a ddl, it does enter to the void int the cs file…

however now I have a question…

I need the Id from the record that it’s stored in a specific row (idCita, as in the buttons I have which use a CommandArgument)… that way can use another class I have which would trigger a query that would edit a field called Estado….

However, I noticed that when I use CommandArguments, I use another void called…

protected void grdvEventosVendedor_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int intIdCita = int.Parse(e.CommandArgument.ToString());

        if (e.CommandName == "Edicion")
        {
            //Some Code
        }

        else if (e.CommandName == "Borrar")
        {
           //More Code
        }

        else if (e.CommandName == "CRM")
        {
            //Even More Code
        }

        else if (e.CommandName == "VerMas")
        {
            //....
        }
    }

with this I can call both e.CommandName which tells me which button I pressed, and e.CommandArgument which is the value for idCita… however I noticed that the ddl void that I previously showed you doesnt have a GridViewCommandEventArgs e, instead it has a EventArgs e…

Is there a way that I can get the value of idCita from the gridview, all the way to the ddl void??

What do I need to add in the gridview code and in the cs file??

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:53:05+00:00Added an answer on June 9, 2026 at 3:53 pm

    Refactor you’re code something like this – it should get you most of the way there, additionally look at converting the else if statements to a more readable switch case statement…

    protected void dpdListEstado_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow gvr = (GridViewRow)(((Control)sender).NamingContainer);   
        MeaningfulNameHere(int.Parse(grdvEventosVendedor.DataKeys[gvr.RowIndex]),"Estado");
    }
    
    protected void grdvEventosVendedor_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        MeaningfulNameHere(int.Parse(e.CommandArgument.ToString()),e.CommandName);
    }
    
    private void MeaningfulNameHere(int id, string commandName)
    {
    
    
        if (commandName == "Edicion")
        {
            //Some Code
        }
    
        else if (commandName == "Borrar")
        {
           //More Code
        }
    
        else if (commandName == "CRM")
        {
            //Even More Code
        }
    
        else if (commandName == "VerMas")
        {
            //....
        }
    
        else if (commandName == "Estado")
        {
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was recently asked this question in an interview. Lets suppose I have 2000
I recently asked a question and posted some code, to which a suggestion was
I recently asked this question. I have a relational database with three tables. The
I recently asked this question and got back a great solution using jquery for
I asked a similar question recently, but didn't get a clear answer because I
This question is very similar to one I recently asked: Python threading- returning control
i recently asked this question on how to have a container div width set
I've asked a similar question recently, and got a great reply on solving a
I recently asked a similar question Close Colorbox iframe after form submit and then
I recently asked a question about using XSL/t for creating a site layout and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.