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

  • Home
  • SEARCH
  • 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 9268307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:46:40+00:00 2026-06-18T14:46:40+00:00

So if the user selects a value from a dropDownList and clicks the button,

  • 0

So if the user selects a value from a dropDownList and clicks the button, the ID is passed to the code behind(which is where I want it)
E.g.

<asp:DropDownList ID="DropDownList" runat="server" AppendDataBoundItems="true" DataTextField="Company_Name" DataValueField="id">
<asp:ListItem Text="---Select---" Value="0" />   
</asp:DropDownList>

So dataValueField will pass the ‘id’ of the selected record in the DD.

However On the same page I am using a repeater to display records that have been previously chosen from the drop down, Beside each record i have a ‘Change Prices’ button which I want to perform a task when clicked, all works fine however all I need is the same ‘id’.
So is this done in a similar way? E.g

<asp:Repeater ID="repeaterShowName" runat="server">             
                <HeaderTemplate>                   
                        <tr>

                            <th>
                                <asp:Label ID="SubConName" Text="Current SubContractors" runat="server"></asp:Label>                               
                            </th>
                        </tr>                   
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <asp:Label ID="SubCon" Text='<%# Bind ("Company_Name")  %>' runat="server"></asp:Label>  
                        </td> 
                        <td>                                     
                            <asp:LinkButton ID="AddNewBOQLink" runat="server"  OnClick="EditPricesForSubContractor" CssClass="bottomhyperlink">Change Prices</asp:LinkButton>
                        </td>

                    </tr>
                </ItemTemplate>
            </asp:Repeater>

//So Do I add in DataValueField=”id” inside the link button, so when the user selects the hyperlink beside the name, it will automatically have the ‘id?

  • 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-18T14:46:41+00:00Added an answer on June 18, 2026 at 2:46 pm

    You should use the CommandArgument property of the LinkButton to pass the id to the method that handles the click.

    So your LinkButton will now look like this:

    <asp:LinkButton ID="AddNewBOQLink" runat="server" CommandArgument='<%# Bind("id")%>'  CssClass="bottomhyperlink">Change Prices</asp:LinkButton>
    

    And you want to add the following property to your Repeater:

    <asp:Repeater .... OnItemCommand="repeater_Command" ...
    

    The method that will handle the command event will look like this

    void repeater_Command(Object Sender, RepeaterCommandEventArgs e) {        
       //retrieve the id like so
       int id = (int)e.CommandArgument;
    }
    

    Also, note that I removed the OnClick property from the LinkButton. It is not needed as you are handling the click via the repeater’s OnItemCommand method.

    In addition, you may want to consider adding a CommandName propery to the LinkButton. This is used to identify which command you wish to execute. Currently, you only have a single command: Change Prices. But in the future you may want to add an additional button with a different command.

    In order to do this, add the following property to the LinkButton:

    <asp:LinkButton ... CommandName="ChangePrice" ...
    

    And modify the repeater_Command method to handle the CommandName. Like so:

    void repeater_Command(Object Sender, RepeaterCommandEventArgs e) {    
       switch(e.CommandName)
       {
          case "ChangePrice":    
             //retrieve the id like so
             int id = (int)e.CommandArgument;
             break;
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The user selects a state from a drop-down field, then ajax posts that value
I have DropDownList, which has some options to choose from. Now after when user
I had trouble getting the value a user selected from a DropDownList. I've figured
When the user select an item from a dropdownlist and presses a button, my
What I'm trying to do is, I'm asking user to select a value from
I have the following select list from which the user can select multiple values.
drop down value not appearing for second list , tried everything .When user selects
I have a radio button with values, Yes and No. If user selects Yes,
When a user selects a file, I want another file field to appear. It
In an ASP.Net VB.Net code-behind file, can you tell me what event fires that

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.