Solved

Change web form parameter source from querystring to control after form loads.

Posted on 2008-09-29
3
528 Views
Last Modified: 2008-10-01
I would like to open a webform using a query string to pass parameters then allow the user to makes selections from ddls to further filter the form. There will be a gridview on the webform. How would I go about doing this? Thanks for any help.
0
Comment
Question by:AkAlan
  • 2
3 Comments
 
LVL 10

Expert Comment

by:jinn_hnnl
Comment Utility
You mean you want to select some value in that new webform gridview and return it back to the page for further step???

There are several way doing this, you can simply using javascript to set value for the opener (the page you had this new webform opened). Look at the code example.

If you opened webform is simple, I would recommend you to NOT open a new page, make it a simple div within your original page, and invisible it when inactive, open when you need to.
There are several nice ways to do it. You can take a look at ModalPopupExtender (ajax tool - free)

http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx

JINN




In your grid view, one of the button click has this event attribute (javascript)
 

function ReturnvalueToMyPage(valueSelected) {

  if (window.opener && !window.opener.closed)

    window.opener.document.myform.textbox.value = valueSelected;

  window.close();

}

Open in new window

0
 
LVL 6

Author Comment

by:AkAlan
Comment Utility
Jinn, I think maybe I haven't made my question clear enough. I want to open a web form that has a parameterized gridview by passing in parameters using a querystring. Once the new form is open I want to be able to perform a filter of the records by allowing the user to make selections from ddls. The problem is that the datasource for the grid view is configured to accept only query string parameters and I want to know the best way to refresh the page with the new parameters that were selected from the ddls. Should I do a redirect to the same web page with a querystring created from the ddls? Is there a better way that I should look at? Thanks
0
 
LVL 10

Accepted Solution

by:
jinn_hnnl earned 500 total points
Comment Utility
Hold on,

I guess there are more information appeared on that new web form, you have a dropdown list, and the datasource of the GridView looks at this control (or anything else to rebind its source).

The ddls has the event OnSelectedIndexChange (or something like that). This event will cause the page to post back. On serverside, you just have to get selectedValue of that ddls, rebind the Gridview datasource.

This is done programatically, so if your gridview configured by only accepting the query string let say you have:

string private m_MyQueryStringValuepublic string MyQueryStringValue(){         get {return Context.Request.QueryString("someqr"); }         set{ m_MyQueryStringValue = value; }}
Then in your selected indexChange of the ddls you just have to set one more:
MyQueryStringValue = ddls.SelectedValue;

Actually you dont even have to do it, cause you can bind directly regardless how your querystring is like.

The best way to do it (we have similar scenarios) is using UpdatePanel. It's standard component of ASP.NET. Quite simple, You might wanna put your Gridview & ddls in that UpdatePanel.

JINN
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now