locked
About asp:ControlParameter and selectParameters RRS feed

  • Question

  • User-1699418546 posted

    Hello everyone,

    I have tow gridview contral in my .aspx file.When I selected one row of the gridview1(connected to sqlDataSource1), the gridview2(connected to sqlDataSource2) changes it result automatically.the code of sqlDataSource2 is:

                <asp:SqlDataSource ID="sqsBasicLine" runat="server">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="GridViewBasicShipowner" Name="shipownerID" PropertyName="selectedDataKey.value" />
                    </SelectParameters>
                </asp:SqlDataSource>

    The other part of the code is in the .cs file.I want to move <asp:ControlParameter ControlID="GridViewBasicShipowner" Name="shipownerID" PropertyName="selectedDataKey.value" />  to the .cs too.But whatever I do,it doesn't work.

    Help me,please.Thank you very much.

    Tuesday, September 13, 2011 1:11 PM

Answers

  • User3866881 posted

    Hello silencezz,

    I suggest you, if you wanna code behind—— You can use Parameter instead of ControlParameter, just like this:

    <asp:SqlDataSource ID="sqsBasicLine" runat="server">
                    <SelectParameters>
                        <asp:Parameter ControlID="GridViewBasicShipowner" Name="shipownerID" Type="Int32" DefaultValue="1" PropertyName="selectedDataKey.value" />
                    </SelectParameters>
    </asp:SqlDataSource>

    And then handle the GridViewBasicShipowner's SelectIndexChanged event, say this:

    sqsBasicLine.SelectParameters["shipownerID"].DefaultValue = GridViewBasicShipowner.SelectedDataKey.Value;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 15, 2011 12:02 AM

All replies

  • User3866881 posted

    Hello silencezz,

    I suggest you, if you wanna code behind—— You can use Parameter instead of ControlParameter, just like this:

    <asp:SqlDataSource ID="sqsBasicLine" runat="server">
                    <SelectParameters>
                        <asp:Parameter ControlID="GridViewBasicShipowner" Name="shipownerID" Type="Int32" DefaultValue="1" PropertyName="selectedDataKey.value" />
                    </SelectParameters>
    </asp:SqlDataSource>

    And then handle the GridViewBasicShipowner's SelectIndexChanged event, say this:

    sqsBasicLine.SelectParameters["shipownerID"].DefaultValue = GridViewBasicShipowner.SelectedDataKey.Value;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 15, 2011 12:02 AM
  • User-1699418546 posted

    Thank you very much。I'll try it。

    Monday, September 19, 2011 2:53 AM