jofreder
Posts: 10
|
Posted: 11/23/2006, 9:26 PM |
|
My Grid Is setup to get data from a stored procedure and takes one parameter. I need the parameter to come from a Listbox at the top of the page. So, how do I select from the listbox and populate my grid.
I am using .NET 2.0 C#
Thanks
|
|
|
Diesel
Posts: 43
|
Posted: 11/30/2006, 1:23 AM |
|
Hi there
Ok, so you have a Grid that is populated with a Stored Proc that gives a @Return_Value from which you get your columns and data. Now for your Stored Proc to work correctly you need to pass a parameter to the Stored Proc and then populate the grid accordingly.
Lets assume that the Listbox name is ListboxExample and the Form Name is GridForm
Therefore you need to add the following code on the onchange client-side event of the listbox:
reload_page();
The code for this function must be put in the header part of your page:
function reload_page() {
var sel_index = theForm.GridFormListboxExample.options[theForm.GridFormListboxExample.selectedIndex].value;
if (sel_index != "") {
document.location.href = document.location.pathname + "?" + "ListboxExample=" + sel_index;
}
}
What happens when doing this?
You pass the value of the listbox that you need for the grid to the url which can now be picked up from the Stored Proc in the Grid.
How?
Create a new parameter in the DataSource where you have your Stored Proc @Return_Value
Depending on the datatype the parameter settings will differ. I am going to assume that the value is an integer.
Thus:
Stored Procedure Parameter
Parameter Name: @ListboxExample
Data Type: Integer
Data size: 0
Direction: Input
Scale: 0
Precision: 10
Parameter
Parameter Name: ListboxExample
Data Type: URL
Format:
Thats it! Compile and it works!
Zack
|
|
|
|