Passing values
eveloc | Posted 12:06am 8. April 2008 Server Time |
I have a simple form that asks for two values, streetnumber and streetname. It needs to be passed to a stored procedure in a Gridview. This gridview is on a separate page. Is this like the old ASP where you use a request.querystring to get the values? |
hotwu | Posted 9:21pm 10. April 2008 Server Time |
You can still use Request.QueryString and manually load the grid yourself, but there are easier ways to work with the GridView. In this instance I would create a method in a class that calls your stored procedure and accepts two variables that represent your streetnumber and streetname. Make sure this method returns a dataset or a typed list ~ whatever you are going to use to populate your GridView. Add an ObjectDataSource to your GridView and select the class you created, after you do this it will also ask you to select the method to fill the list. Select your method... you have the option as you proceed to select the source of the variables that will be passed into the select method. You can set the ObjectDataSource to load the variables from the QueryString and specify the variable names (and their default values in case they are non existant). Using the DataGrid this way eliminates all code behind code and puts the data/business logic where it belongs. It also makes it extremely easy to add inline updating and deleting. By using the 3.5 framework and LINQ you can bypass handcoding in situations like this entirely.
Reply to Post Passing values
|
|
|