开发者

modifying the query string on dropdown index change in asp code behind

Hi I have a drop down box that is in the edit template of a formview. I want to be able to add a parrameter to the querystring when the drop down selected index is changed.

I tried

     Request.QueryString.Add("tabindex", (sender as WebControl).TabIndex.ToString());

But I got an exception saying the collection is readonly.

Here is my markup

  <icms_ref:ReferenceDropDownList ReferenceDataManagerProviderName="ROCSQLReferenceDataProvider"
                    ID="ddlEnquirerHearType" TabIndex="2" runat="server" ReferenceSetName="EnquiryHearType"
                    AutoPostBack="true" OnSelectedIndexChanged="EnquirerHearType_SelectedIndexChanged"
                    DataTextField="ShortName" DataValueField="ReferenceId" />

and here is my code behind.

 protected void EnquirerHearType_SelectedIndexChanged(object sender, EventArgs e)
    {
        var pnlEnquiryHearTypeOther = fvEnquiryInformation.FindControl("pnlEnquiryHearTypeOther") as Panel;
        pnlEnquiryHearTypeOther.Visible = DdlEnquirerHearType.SelectedValue == ((int)EnquiryHearType.Other).ToString();

        ResetTextBox("txtEnquiry开发者_如何学运维HearTypeOther", fvEnquiryInformation);

        Request.QueryString.Add("tabindex", (sender as WebControl).TabIndex.ToString());

    }


You can't directly add to the QueryString collection, you have to Response.Redirect to the new Url (modifying the URL to add in the query parameter yourself).

 string url = HttpContext.Current.Request.Url.AbsoluteUri + "?tabindex=blah";
Response.Redirect(url, true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜