Ads

Monday, 1 July 2013

Build dynamic query string in sharepoint

public string BuildQueryString()
    {
        string url = HttpContext.Current.Request.Url.AbsoluteUri;
        string[] separateURL = url.Split('?');

        NameValueCollection queryString = System.Web.HttpUtility.ParseQueryString("");
        if (ddlLegalAdvisor.SelectedIndex > 0)
        {
            queryString["LegalAdvisor"] = ddlLegalAdvisor.SelectedValue;
        }
        if (ddlAreaOfLaw.SelectedIndex > 0)
        {
            queryString["Areaoflaw"] = ddlAreaOfLaw.SelectedValue;
        }
        if (ddlFundingStream.SelectedIndex > 0)
        {
            queryString["FundingStream"] = ddlFundingStream.SelectedValue;
        }
        if (ddlInterviewRoom.SelectedIndex > 0)
        {
            queryString["InterviewRoom"] = ddlInterviewRoom.SelectedValue;
        }
        url = separateURL[0] + "?" + Convert.ToString(queryString);
        return url;

    }

No comments:

Post a Comment

Ads