how to pass values between two repeateres on the same page

I have two repeaters that looks like this :

Arrange By: Name | Age | Area

what I want to do now is to populate the second repeater from the database with the alphabet, and if the age was clicked then the second repeater gets populated from the database with some age ranges!

I already implemented my idea by placing a hyperlink in the first repeater, that passes -using it's NavigateUrl property- a url for the same page but with some querystring values!

I've been told that querystrings are used for passing values from one page to another, not the same page...and also I wanted to use some AJAX (script manager and update panel) but turns out that I have to use some server control within my repeater instead of html controls so it could be able to post back to the server

I hope you'd help me with a good implementation for passing the value from repeater1 to repeater2 and if you think that I've stated anything wrong Please Corret Me!

Thanks in advance :)



protected void Page_Load(object sender, EventArgs e)
            string commandString1 = "SELECT [arrange_by_id], [arrange_by] FROM [arrange_by]";

            using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                using (SqlCommand cm = new SqlCommand(commandString1, cn))

                    using (SqlDataReader dr = cm.ExecuteReader())
                        ArrangeBy_rpt.DataSource = dr;

    void arrange_lnkbtn_command(object sender, CommandEventArgs e)
         Label1.Text = (e.CommandArgument).ToString();


    <asp:Repeater ID="ArrangeBy_rpt" runat="server">
          <asp:LinkButton id="arrange_lnkbtn" OnCommand="arrange_lnkbtn_command" CommandArgument='<%#Eval("arrange_by_id") %>' runat="server">
          <%# Eval("arrange_by") %>
       <SeparatorTemplate> | </SeparatorTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Compilation Error

Compiler Error Message: CS1061: 'ASP.sortingcontrol_ascx' does not contain a definition for 'arrange_lnkbtn_command' and no extension method 'arrange_lnkbtn_command' accepting a first argument of type 'ASP.sortingcontrol_ascx' could be found (are you missing a using directive or an assembly reference?)

Line 4:  <asp:Repeater ID="ArrangeBy_rpt" runat="server">
Line 5:     <ItemTemplate>
Line 6:        <asp:LinkButton id="arrange_lnkbtn" OnCommand="arrange_lnkbtn_command" CommandArgument='<%#Eval("arrange_by_id") %>' runat="server">
Line 7:        <%# Eval("arrange_by") %>
Line 8:        </asp:LinkButton>


There's nothing wrong per se with passing data to the same page using the querystring, though it shouldn't be used for sensitive data that the user might change by "hacking" the URL. However, it's not the standard way of doing things in ASP.NET WebForms, since it won't postback the values of any other controls on the page (and hence they won't retain their state without you manually having to re-populate them on every page load). But if this is not a problem for you, feel free to stick with querystring.

Howecer, generally you would use a server-side control like an asp:Button or an asp:LinkButton and then handle their OnClick event. However, to pass data with one you can use the CommandName and CommandArgument properties of the button and then handle the OnCommand event.

 <asp:LinkButton id="LinkButton1" 
           Text="Click Me"

In code-behind:

  void LinkButton_Command(Object sender, CommandEventArgs e) 
     var data = GetData(e.commandArgument); // implement a method that gets your data filtered by the argument passed from the button
     Repeater2.DataSource = data;

Need Your Help

Android Browser orientationchange event keeps firing

javascript android events browser orientation

Following is simple html, when viewed on android browser(nexus one) results into continuos orientationchange event chain when you change phone's orientation just once.&lt;html>&lt;body>

OGL ES 2.0 Texture on plane

java android opengl-es-2.0 textures

I'm having troube displaying a texture to a plane of two triangles.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.