locked
GridView multiple datakeysname RRS feed

  • Question

  • User-2059803096 posted

    Hi all

    I have a gridview with 2 datakeysName  <asp:GridView ID="GridVendutoPivot" DataKeyNames="cd_ar,cd_do" ...

    I have to pass these value to another gridview, 

    <asp:SqlDataSource ID="dsMovimenti" runat="server" SelectCommand=SELECT * FROM MyTab WHERE (([Cd_DO] = @Cd_DO) AND ([Cd_AR] = @Cd_AR))  ..

     <SelectParameters>
                 <asp:ControlParameter ControlID="GridVendutoPivot" Name="Cd_DO" PropertyName="SelectedValue" Type="String" />
                 <asp:ControlParameter ControlID="GridVendutoPivot" Name="Cd_AR" PropertyName="SelectedValue" Type="String" />
             </SelectParameters>

    it doesn't work. Can you help me to understand? tks a lot

    Massimiliano

    Tuesday, December 8, 2020 9:52 AM

All replies

  • User753101303 posted

    Hi,

    You don't have any error message but it doesn't select what you want? At best it likely assign the same value to both parameters.

    Waht if you try instead:

    <asp:ControlParameter ControlID="GridVendutoPivot" Name="Cd_DO" PropertyName="SelectedDataKey[1]" Type="String" />
    <asp:ControlParameter ControlID="GridVendutoPivot" Name="Cd_AR" PropertyName="SelectedDataKey[0]" Type="String" />

    Tuesday, December 8, 2020 10:31 AM
  • User-2059803096 posted

    PatriceSc

    Hi,

    You don't have any error message but it doesn't select what you want? At best it likely assign the same value to both parameters.

    Waht if you try instead:

    <asp:ControlParameter ControlID="GridVendutoPivot" Name="Cd_DO" PropertyName="SelectedDataKey[1]" Type="String" />
    <asp:ControlParameter ControlID="GridVendutoPivot" Name="Cd_AR" PropertyName="SelectedDataKey[0]" Type="String" />

    DataBinding: 'System.String' doesn't allow index access.

    Tuesday, December 8, 2020 3:03 PM
  • User-2059803096 posted

    Hi,

    You don't have any error message but it doesn't select what you want? At best it likely assign the same value to both parameters.

    Waht if you try instead:

    <asp:ControlParameter ControlID="GridVendutoPivot" Name="Cd_DO" PropertyName="SelectedDataKey[1]" Type="String" />
    <asp:ControlParameter ControlID="GridVendutoPivot" Name="Cd_AR" PropertyName="SelectedDataKey[0]" Type="String" />

    Sorry, it works, tks a lot

    Massimiliano

    Tuesday, December 8, 2020 3:24 PM