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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:45:33+00:00 2026-05-18T20:45:33+00:00

I once asked for a way to let a linkbutton pass more than one

  • 0

I once asked for a way to let a linkbutton pass more than one value in the commandArgument and then I reached the approach where I pass a string of multiple values separated by any character and split it into it’s original parts…that didn’t work out I don’t know what was wrong with the splitting!

Now I tried the only solution I got, which is created a user control of the LinkButton and add properties to accept any values nedeed!…could you please tell me what’s wrong with my 2 approaches and which is better ?

The first question can be found here : link text

and this is the code for the user control approach >>

MultivaluedLinkButton.ascx :

<asp:LinkButton ID="LnkBtnSort" runat="server" Text="Sort" OnClick="LnkBtnSort_Clicked"/>

MultivaluedLinkButton.ascx.cs :

public partial class MultivaluedLinkButton : System.Web.UI.UserControl
{
    public event EventHandler Click;
    private int _sortingType;
    private string _sortingFactor;
    private string _text;

 public int SortingType 
 { 
     set { _sortingType = value; } 
     get { return _sortingType; } 
 }

 public string SortingFactor
 {
     set { _sortingFactor = value; } 
     get { return _sortingFactor.ToString(); }
 }

 //public string Text
 //{
 //    set { _text = value; }
 //    get { return _text.ToString(); }
 //}

 protected void LnkBtnSort_Clicked(object sender, EventArgs e)
 {
     if( Click != null )
     {
         this.Click(this, EventArgs.Empty);
     }
 }

}

Finally, Here’s the implementation of my control inside an aspx page:

    protected void MultivaluedLinkButton1_Clicked(object sender, EventArgs e)
    {

        MultivaluedLinkButton ctrl = (MultivaluedLinkButton)sender;

        using (SqlConnection cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
        {
            using (SqlCommand cm1 = new SqlCommand(commandString2, cn1))
            {

                cm1.Parameters.Add("@arrange_by_id", System.Data.SqlDbType.Int);
                cm1.Parameters["@arrange_by_id"].Value = ctrl.SortingType;
                cn1.Open();
                using (SqlDataReader dr1 = cm1.ExecuteReader())
                {
                    SortBy_rpt.DataSource = dr1;
                    SortBy_rpt.DataBind();
                }
            }
        }
    }

The item template of the repeater in the implementation page :

   <ItemTemplate>
   <uc1:MultivaluedLinkButton ID="MultivaluedLinkButton1" runat="server" OnClick="MultivaluedLinkButton1_Clicked" SortingType='<%#Eval("arrange_by_id")%>' />
   </ItemTemplate>
  • 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-18T20:45:34+00:00Added an answer on May 18, 2026 at 8:45 pm

    The problem i see is, you have an eventHandler in your usercontrol which you never really use.

    Not 100% sure but, on the Page_Load of your parent page, you need to add MultivaluedLinkButton1_Clicked event to your handler.

    MultivaluedLinkButton1.EventHandler_Click = new EventHandler(this.MultivaluedLinkButton1_Clicked);
    MultivaluedLinkButton1.LnkBtnSort.Click = MultivaluedLinkButton1.EventHandler_Click;
    

    Basically you are telling that when a user clicks on your linkbutton, MultivaluedLinkButton1_Clicked() on the parent page should be called.

    You can remove OnClick=”MultivaluedLinkButton1_Clicked” from your UserControl properties on your parent page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.