hi
I have 2 grids in one page. For example, Order Grid and Order Detail Grid
The Order Grid has paging enabled.
How do i pass the orderid on the Order Grid to Order Detail Grid and i page from page 1 to page 2 and so on? Thanks
So that when click page 2 on the Order Grid, it should reflect Order Detail of that OrderID on page 2. Thanks
I have 2 grids in one page. For example, Order Grid and Order Detail Grid
The Order Grid has paging enabled.
How do i pass the orderid on the Order Grid to Order Detail Grid and i page from page 1 to page 2 and so on? Thanks
So that when click page 2 on the Order Grid, it should reflect Order Detail of that OrderID on page 2. Thanks
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 07 Dec 2009, 09:59 AM
Helo,
Here is the demo that shows how to use dependant grids.
Grid / Master/Detail Grids
You can attach ItemCommand event to 'Order grid' and set the SqlDatasource (which bound to 'Order detail' grid) SelectParameter from code behind, according to the page changed, and then Rebind the Order Details grid.
-Shinu.
Here is the demo that shows how to use dependant grids.
Grid / Master/Detail Grids
You can attach ItemCommand event to 'Order grid' and set the SqlDatasource (which bound to 'Order detail' grid) SelectParameter from code behind, according to the page changed, and then Rebind the Order Details grid.
-Shinu.
0
L
Top achievements
Rank 1
answered on 07 Dec 2009, 04:26 PM
hi
The Grid / Master/Detail Grids is not suitable for me cause I am having 1 record per page due to too much information on the customer. Anyway here is my shorten code:
<telerik:GridTemplateColumn DataField="Order_ID"
HeaderText="Order Histories"
SortExpression="Order_ID" UniqueName="Order_ID">
<ItemTemplate>
<table cellpadding="0" cellspacing="0" class="style1">
<tr>
<td class="tdcolor">
Customer Name:</td>
<td>
<asp:Label ID="Label2" runat="server"
Text='<%# Eval("Customer_Name") %>'></asp:Label> - <asp:Label ID="Label11" runat="server"
Text='<%# Eval("Customer_ID") %>'></asp:Label></td>
<td>
<asp:Label ID="Label3" runat="server"
Text='<%# Eval("Customer_Address") %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="4">
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Select"
Text="View Order History"></asp:LinkButton></td>
</tr>
</table>
</ItemTemplate>
</telerik:GridTemplateColumn>
As you can see, i am using ItemTemplate to layout my grid. So, effectively, i can only show 1 customer per page due to overwhelming info about customer.
Now, I have link button with a CommandName="Select". How should go about doing it so that when i click View Order History linkbutton, i want the orderid to pass it to a session variable?
I tried using this but it is not working:
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
If e.CommandName = "Select" Then
Dim selectedRow As GridDataItem = DirectCast(e.Item, GridDataItem)
Session("orderid") = selectedRow("Order_ID").Text.ToString()
End If
End Sub
Thanks
The Grid / Master/Detail Grids is not suitable for me cause I am having 1 record per page due to too much information on the customer. Anyway here is my shorten code:
<telerik:GridTemplateColumn DataField="Order_ID"
HeaderText="Order Histories"
SortExpression="Order_ID" UniqueName="Order_ID">
<ItemTemplate>
<table cellpadding="0" cellspacing="0" class="style1">
<tr>
<td class="tdcolor">
Customer Name:</td>
<td>
<asp:Label ID="Label2" runat="server"
Text='<%# Eval("Customer_Name") %>'></asp:Label> - <asp:Label ID="Label11" runat="server"
Text='<%# Eval("Customer_ID") %>'></asp:Label></td>
<td>
<asp:Label ID="Label3" runat="server"
Text='<%# Eval("Customer_Address") %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="4">
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Select"
Text="View Order History"></asp:LinkButton></td>
</tr>
</table>
</ItemTemplate>
</telerik:GridTemplateColumn>
As you can see, i am using ItemTemplate to layout my grid. So, effectively, i can only show 1 customer per page due to overwhelming info about customer.
Now, I have link button with a CommandName="Select". How should go about doing it so that when i click View Order History linkbutton, i want the orderid to pass it to a session variable?
I tried using this but it is not working:
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
If e.CommandName = "Select" Then
Dim selectedRow As GridDataItem = DirectCast(e.Item, GridDataItem)
Session("orderid") = selectedRow("Order_ID").Text.ToString()
End If
End Sub
Thanks
0
Hi L,
Best wishes,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Your general syntax for accessing the item:
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
If e.CommandName = "Select" Then
Dim selectedRow As GridDataItem = DirectCast(e.Item, GridDataItem)
Session("orderid") = selectedRow("Order_ID").Text.ToString()
End If
End Sub
is correct. If this is a standard cell, the value should be retrieved normally. However, if this cell hosts other controls in it, you can try locating them via the .Controls collection for the cell, or via the .FindControl() method of the cell. One of these approaches will get the proper value.
Best wishes,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
L
Top achievements
Rank 1
answered on 23 Dec 2009, 01:42 PM
hi
It is not working. When i did a breakpoint at the Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand, it is empty or nothing.
It seems that <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Select"
Text="View Order History"></asp:LinkButton> is not able to get the Order_ID field. How should I solve this? Thanks
It is not working. When i did a breakpoint at the Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand, it is empty or nothing.
It seems that <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Select"
Text="View Order History"></asp:LinkButton> is not able to get the Order_ID field. How should I solve this? Thanks
0
Accepted
Hi L,
You can add Order_ID to the DataKeyNames collection of the MasterTableView and then get the key value in RadGrid's ItemCommand event:
Best wishes,
Veli
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can add Order_ID to the DataKeyNames collection of the MasterTableView and then get the key value in RadGrid's ItemCommand event:
Dim selectedRow As GridDataItem = DirectCast(e.Item, GridDataItem)Session("orderid") = selectedRow.GetDataKeyValue("Order_ID")Best wishes,
Veli
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.