This is a migrated thread and some comments may be shown as answers.

Related Radgrid And Multiple DataKeyNames

1 Answer 330 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 11 Aug 2008, 02:18 PM

Hello,

I have a form where i put 2 related RadGrid.
The first RadGrid is the parent which contain the list of my SKUs.
My DataKeyNames is composed of 3 elements: Style, Color and Size which is my primary key.

My second RadGrid is the child of the first one.  

So, once i click on any row on the first Grid, i want to display the list of my related POs in my second Grid.

I have done it before with one value and it worked fine. By my only problem, i don't know how to pass my 3 values. I tried to use in my ObjectDataSource PropertyName="SelectedValue" but it didn't work.

Can anyone help me ?

Thank you
Paul


Here's my ASPX code:



<

script language='javascript'>

function

RowSelected()
{
window[
"<%= rgPOs.ClientID %>"].AjaxRequest("<%= rgPOs.UniqueID %>", "");
}
</script>


<radG:RadGrid id="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"

EnableAJAX="True"

GridLines="None" DataSourceID="ObjectDataSource1" Skin="Web20"

OnItemDataBound="RadGrid1_ItemDataBound" AutoGenerateColumns="False">

<clientsettings allowexpandcollapse="True">

<ClientEvents OnRowSelected="RowSelected" />

<Selecting AllowRowSelect="True"></Selecting>

</clientsettings>

<mastertableview datasourceid="ObjectDataSource1" pagesize="20"

DataKeyNames="Style,Color,Size">

<AlternatingItemStyle BackColor="Gainsboro" Wrap="True" Font-Italic="False" Font-Strikeout="False" Font-Underline="False" Font-Overline="False" Font-Bold="False"></AlternatingItemStyle>

<Columns>

<radG:GridBoundColumn DataField="Style" UniqueName="Style" HeaderText="Style"></radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Color" UniqueName="Color" HeaderText="Color"></radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Size" UniqueName="Size" HeaderText="Size"></radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Quantity_Ordered" UniqueName="Quantity_Ordered" HeaderText="Ordered">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Quantity_In_Production" UniqueName="Quantity_In_Production" HeaderText="In Production">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Quantity_Produced" UniqueName="Quantity_Produced" HeaderText="Produced">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Quantity_Shipped" UniqueName="Quantity_Shipped" HeaderText="Shipped">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Quantity_To_Produce" UniqueName="Quantity_To_Produce" HeaderText="Units To Produce">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Balance_To_Produce" UniqueName="Balance_To_Produce" HeaderText="Balance To Produce">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radg:GridTemplateColumn UniqueName="TemplateEditColumn">

<ItemTemplate>

<asp:HyperLink ID="ViewPO" runat="server" Text="View POs"></asp:HyperLink>

</ItemTemplate>

</radg:GridTemplateColumn>

<radg:GridTemplateColumn UniqueName="TemplateEditColumn">

<ItemTemplate>

<asp:HyperLink ID="ProductionStatus" runat="server" Text="Production status"></asp:HyperLink>

</ItemTemplate>

</radg:GridTemplateColumn>

<radg:GridTemplateColumn UniqueName="TemplateEditColumn">

<ItemTemplate>

<asp:HyperLink ID="Move2Production" runat="server" Text="Move to production"></asp:HyperLink>

</ItemTemplate>

</radg:GridTemplateColumn>

<radg:GridTemplateColumn UniqueName="TemplateEditColumn">

<ItemTemplate>

<asp:HyperLink ID="Move2Produced" runat="server" Text="Move to produced"></asp:HyperLink>

</ItemTemplate>

</radg:GridTemplateColumn>

</Columns>

<ExpandCollapseColumn>

<HeaderStyle Width="19px"></HeaderStyle>

</ExpandCollapseColumn>

<RowIndicatorColumn Visible="False">

<HeaderStyle Width="20px"></HeaderStyle>

</RowIndicatorColumn>

</mastertableview>

</radG:RadGrid>


<!-- -------------------------------------------------------------------- -->
<!-- List of POs -->
<!-- -------------------------------------------------------------------- -->

<radG:RadGrid id="rgPOs" runat="server" AllowPaging="True" AllowSorting="True"

EnableAJAX="True" DataSourceID="ObjectDataSource2" ShowStatusBar="true"

GridLines="None" Skin="Web20">

<clientsettings>

<Selecting AllowRowSelect="True"></Selecting>

</clientsettings>

<MasterTableView pagesize="20" autogeneratecolumns="False" DataKeyNames="PO_No">

<AlternatingItemStyle BackColor="Gainsboro" Wrap="True" Font-Italic="False" Font-Strikeout="False" Font-Underline="False" Font-Overline="False" Font-Bold="False"></AlternatingItemStyle>

<Columns>

<radG:GridBoundColumn DataField="PO_No" UniqueName="PO_No" HeaderText="PO #"></radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Quantity_Ordered" UniqueName="Quantity_Ordered" HeaderText="Units Ordered">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Quantity_In_Production" UniqueName="Quantity_In_Production" HeaderText="Units in Production">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Quantity_Produced" UniqueName="Quantity_Produced" HeaderText="Units Produced">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Quantity_To_Produce" UniqueName="Quantity_To_Produce" HeaderText="Units To Produce">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Balance_To_Produce" UniqueName="Balance_To_Produce" HeaderText="Balance To Produce">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Estimated_Completed_Date" UniqueName="Estimated_Completed_Date" HeaderText="ECD" DataFormatString = "{0:dd-MM-yyyy}" >

<ItemStyle width="70px"></ItemStyle>

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Days_In_Production" UniqueName="Days_In_Production" HeaderText="Days in Production">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

</radG:GridBoundColumn>

</Columns>

<RowIndicatorColumn Visible="False">

<HeaderStyle Width="20px"></HeaderStyle>

</RowIndicatorColumn>

</mastertableview>

</radG:RadGrid>


<!-- -------------------------------------------------------------------- -->
<!-- Data source -->
<!-- -------------------------------------------------------------------- -->

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="FetchSKUByStage"

TypeName="PO_Tracking_WS.Service">

<SelectParameters>

<asp:Parameter DefaultValue="02,04" Name="p_stage" Type="String" />

<asp:Parameter DefaultValue="2" Name="p_indicator" Type="Int32" />

</SelectParameters>

</asp:ObjectDataSource>

<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"

SelectMethod="FetchSKUInALLPOs" TypeName="PO_Tracking_WS.Service">

<SelectParameters>

<asp:ControlParameter ControlID="RadGrid1" Name="p_style" PropertyName="SelectedValue" Type="String" />

<asp:ControlParameter ControlID="RadGrid1" Name="p_color" PropertyName="SelectedValue" Type="String" />

<asp:ControlParameter ControlID="RadGrid1" Name="p_size" PropertyName="SelectedValue" Type="String" />

<asp:Parameter DefaultValue="2" Name="p_indicator" Type="Int32" />

<asp:Parameter DefaultValue="04" Name="p_stage" Type="String" />

</SelectParameters>

</asp:ObjectDataSource>

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 14 Aug 2008, 08:12 AM
Hi Paul,

One possible approach in this case, would be to bind the first grid with a standard DataSource control.
For the second grid, if the Datasource control does not offer enough flexibility, through its parameters, to correlate the data to the first grid, you can use a NeedDataSource event handler and implement a custom query, to fetch only the specific rows of data. Alternatively, you can alter the select statement of the second DataSource control, and meet your requirements by using a Where clause for example.
These options should give you enough flexibility to meet your requirements.

Kind regards,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or