Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello all i want to pass multiple arrays variable in query string.

for example i have three checkbox list Brand ,Price, Attribute

any arrays variable may have more than one value key

arrays variable are fixed for checkboxlist

1-checkbox list Brand has Brand []arrays variable

2-checkbox list Price has Price []arrays variable

3-checkbox list Attribute has Attribute []arrays variable

now i have selecting two -two item from every checkbox list .



than i want to query string something like this

C#
www.defualt.aspx?brand[]=samsung=123&apple=11,Price[]=100=12&200=2,Attribute []=camera=1&display=2



plz suggest me how to possible it ?
Posted
Updated 17-Mar-15 3:28am
v2
Comments
Maciej Los 17-Mar-15 8:50am    
Use Session or cookies!

You can do it however you want to do it so long as it is a valid querystring.

For example, you could do ?brand=samsung,123|apple,11&price=100,12|200,

You can choose whatever you want to delimit the values then when you are retrieving Request.QueryString["brand"] you'll then want to use the Split function to break them back out.

Also, this is just an example, make sure to use UrlEncode() to actually encode the url since whatever character you choose as a delimiter may need encoding.
 
Share this answer
 
You can use HTML5 Local Storage for this. Otherwise, I would suggest you to fetch these from database on that page and show them.

However, I was checking the Flipkart site. It is sending parameters somewhat like you.
http://www.flipkart.com/laptops/pr?p%5B%5D=facets.brand%255B%255D%3DAsus&p%5B%5D=facets.brand%255B%255D%3DDell&sid=6bo%2Cb5g&q=laptop&ref=f3c96052-246e-479a-83e9-d798d3770845[^].

Here I have selected Asus and Dell as my laptop filters. It has added the parameters in URL only, but they are encoded. So, encode the URL and try to use in this format, if you can. Here %5B%5D is encoded for [].
 
Share this answer
 
Comments
manvendra patel 17-Mar-15 9:35am    
Sir I want actually mention ur link type (flipkart) .but no idea coming in my mind how to solve this .pls suggest me or provide code
What help you need? You just need to append appropriate parameter and values in the query.
XML
okey i am created simple code something like this

<pre>  protected void Button1_Click(object sender, EventArgs e)
    {

        ArrayList brandarray = new ArrayList();
        brandarray.Add("brand");
        brandarray.Add("brand2");
        brandarray.Add("brand3");
        brandarray.Add("brand4");


        string arry = String.Join(",", ((string[])brandarray.ToArray(typeof(String))));


        ArrayList pricearr1 = new ArrayList();
        pricearr1.Add("price");
            pricearr1.Add("price2");
            pricearr1.Add("price3");
            pricearr1.Add("price4");


            string arry1 = String.Join(",", ((string[])pricearr1.ToArray(typeof(String))));

            ArrayList Attributearray = new ArrayList();
            Attributearray.Add("Attribute");
            Attributearray.Add("Attribute2");
            Attributearray.Add("Attribute3");
            Attributearray.Add("Attribute4");


            string arry12 = String.Join(",", ((string[])Attributearray.ToArray(typeof(String))));


            Response.Redirect("Default.aspx?brand=" + arry + " &amp;price=" + arry1 + " &amp;Discount=" + arry12);
    }</pre>

and my query string coming like

<blockquote class="quote"><div class="op">Quote:</div>http://localhost:49252/Default.aspx?brand=brand,brand2,brand3,brand4%20&price=price,price2,price3,price4%20&Discount=Attribute,Attribute2,Attribute3,Attribute4

please anyone tell me that is right or wrong way</blockquote>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900