views:

134

answers:

2

My problem scenario is as follows:

I have one GridviewA bound to a objectdatasourceA. When I click on a GridviewA row, I want another objectdatasourceB to pick the ID from the GridViewA and then fetch records for GridviewB. This is like masterdetail.

Can i do this and how to use javascript/jqueryscript to make it smooth.

A: 

Your inner objectdatasource should be look like

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Getmethod"
                TypeName="namespace">
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView1" Name="YourFieldName" PropertyName="SelectedValue"
                        Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
Muhammad Akhtar
A: 

firstly make sure you have set the dataKey property on your gridview A to be the ID property of the underlying object (or whatever you want to pass through to objectDataSource B's select method)

then go to objectDataSource B, configure it, choose your select method which accepts a parameter, and then click next. it will ask you where to get that parameter from (i think you can choose between control, session and something else) and select control, it will populate a list of all the controls on the page and select your gridview A.

this will pass on the selected rows dataKey from gridview A to the method linked to objectDataSource B. the select code will run and your gridview B will then display the required subset. if you select a new row in gridView A, it will automatically update gridview B to show the required data.

you can do this with pretty much no code behind written assuming your methods are set up correctly. if you are going to do this have a look at some of the caching methods available as it can be quite bandwidth heavy depending on the size of your recordsets..

spaceman