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 7678447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:39:00+00:00 2026-05-31T17:39:00+00:00

I currently have an asp:GridView that displays a few BoundFields and then one asp:TemplateField

  • 0

I currently have an asp:GridView that displays a few BoundFields and then one asp:TemplateField that holds an asp:DropDownList. I can add multiple rows to the grid and edit each of them individually.

What I need to find out is how I can get the selected value of the current DropDownList being edited in the current row.

I’ve tried using the following code in a function that I call on my link button:

var product = $('.selectedItem').val();

But this code only ever returns the value of whichever row is first. So even though I’m editing the DropDown in the 3rd row and selecting the 5th value, if the 1st row’s value was 2, it will only ever return two.

My html for the DropDown:

 <asp:TemplateField HeaderText="Vendor">
     <ItemTemplate>
        <asp:HiddenField ID="hidEntityID" runat="server" Value='<%# Eval("SomeID") %>' />
        <asp:DropDownList ID="ddlList" runat="server" DataSourceID="dsList" DataTextField="Value" DataValueField="ID" Font-Names="Verdana" Font-Size="11px" ForeColor="#2D2D2D" ClientIDMode="Static" CssClass="selectedItem" OnDataBound="ddlEntity_DataBound">
            <asp:ListItem Value="-1">--- Select ---</asp:ListItem>
        </asp:DropDownList>
        <asp:ObjectDataSource ID="dsList" runat="server" SelectMethod="GetList" TypeName="SomeClass" OldValuesParameterFormatString="original_{0}"></asp:ObjectDataSource>
     </ItemTemplate>
 </asp:TemplateField>

My link button in the Grid:

 <ItemTemplate>
       <a href="#" onclick='addEditDetail(<%# Eval("ID") %>)'>Detail</a>
 </ItemTemplate>

Basically what I need is to find the current index of the row I’m editing or selecting to ‘edit’ and then only get the value of that specific DropDown.

Any suggestions would be awesome.

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-05-31T17:39:01+00:00Added an answer on May 31, 2026 at 5:39 pm

    Yes it will always return first dropdown as your selector is requesting the default link button.
    $(‘.selectedItem’) will return all dropdowns keeping first one as default.

    Your link button click event should be:

     <ItemTemplate>
           <a href="#" onclick='addEditDetail(this)'>Detail</a>
     </ItemTemplate>
    
     function addEditDetail(linkBtn)
    {
        var currentDropDown = $(linkBtn).closest("tr").find("select[id*='ddlList']");
        alert(currentDropDown.val());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an ASP.NET GridView that displays a few columns to the user
I currently have a gridview that has an asp:ButtonField as one of the columns.
I have a fairly standard ASP.NET GridView that displays 2 columns that have a
I currently have a Gridview that displays TypeID , Name , Description. I would
In one of the ASP .Net site we are currently working we have a
I have a Web Role that is using the ASP.NET SQL Membership provider. Currently
I have a project that needs to be done using ASP.NET. Currently, I'm using
I have a page that houses an asp GridView and I would like to
I have an ASP.NET Panel that has a gridview inside of it. Below is
I have an ASP.NET control that I have bound to a SQL result: <asp:GridView

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.