Having some difficulties working with the MasterTable and the DetailTable within my Grid. I have it to the point I would like it but need some minor adjustments and I believe I have what I am looking for.
How do I get the CartID from the MasterTable passed to my DetailTable Datasource.
<
telerik:RadGrid
ID
=
"_grdHistory"
runat
=
"server"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
GridLines
=
"None"
>
<
MasterTableView
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"CartID"
DataSourceID
=
"SqlDataSource3"
Width
=
"100%"
runat
=
"server"
EnableHeaderContextMenu
=
"false"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"CartID"
MasterKeyField
=
"CartID"
>
</
telerik:GridRelationFields
>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridBoundColumn
SortExpression
=
"CartID"
HeaderText
=
"CartID"
DataField
=
"CartID"
UniqueName
=
"CartID"
Display
=
"True"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"ItemName"
HeaderText
=
"Item Name"
DataField
=
"ItemName"
UniqueName
=
"ItemName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"ItemCnt"
HeaderText
=
"Item Cnt"
DataField
=
"ItemCnt"
UniqueName
=
"ItemCnt"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"TotItemCost"
HeaderText
=
"Item Cnt"
DataField
=
"TotItemCost"
UniqueName
=
"TotItemCost"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
RowIndicatorColumn
Visible
=
"True"
FilterControlAltText
=
"Filter RowIndicator column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
Visible
=
"True"
FilterControlAltText
=
"Filter ExpandColumn column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridHyperLinkColumn
AllowSorting
=
"False"
FilterControlAltText
=
"Filter InvoiceID column"
HeaderText
=
"INVOICE #"
UniqueName
=
"InvoiceID"
DataNavigateUrlFields
=
"InvoiceID"
DataNavigateUrlFormatString
=
"OrderHistoryDetail.aspx?ID={0}"
DataTextField
=
"InvoiceID"
Target
=
"_blank"
>
</
telerik:GridHyperLinkColumn
>
<
telerik:GridBoundColumn
DataField
=
"Order_Date"
FilterControlAltText
=
"Filter column1 column"
HeaderText
=
"ORDER DATE"
UniqueName
=
"column1"
DataFormatString
=
"{0:MM/dd/yyyy}"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Order_Amt"
FilterControlAltText
=
"Filter column1 column"
HeaderText
=
"ORDER AMOUNT"
UniqueName
=
"column1"
DataFormatString
=
"{0:c}"
ItemStyle-HorizontalAlign
=
"Right"
>
<
ItemStyle
HorizontalAlign
=
"Right"
></
ItemStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"OrderedByName"
FilterControlAltText
=
"Filter column1 column"
HeaderText
=
"ORDERED BY"
UniqueName
=
"column1"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Shipped"
FilterControlAltText
=
"Filter column1 column"
HeaderText
=
"SHIPPED"
UniqueName
=
"column1"
DataFormatString
=
"{0:MM/dd/yyyy}"
>
</
telerik:GridBoundColumn
>
<
telerik:GridHyperLinkColumn
AllowSorting
=
"False"
DataTextField
=
"FedExTrack"
DataNavigateUrlFields
=
"FedExTrack"
FilterControlAltText
=
"Filter column3 column"
ImageUrl
=
"~/images/FedEx-Shipping-Box-icon.png"
DataNavigateUrlFormatString
=
"http://www.fedex.com/Tracking?action=track&;tracknumbers={0}"
UniqueName
=
"FedExTrack"
Target
=
"_blank"
>
</
telerik:GridHyperLinkColumn
>
<
telerik:GridBoundColumn
DataField
=
"Approved"
FilterControlAltText
=
"Filter column1 column"
UniqueName
=
"Approved"
ItemStyle-HorizontalAlign
=
"Right"
Display
=
"False"
>
<
ItemStyle
HorizontalAlign
=
"Right"
></
ItemStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CartID"
FilterControlAltText
=
"Filter CartID column"
UniqueName
=
"CartID"
ItemStyle-HorizontalAlign
=
"Right"
Display
=
"False"
>
<
ItemStyle
HorizontalAlign
=
"Right"
></
ItemStyle
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
td
></
tr
>
</
table
>
</
td
>
</
tr
>
</
table
>
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
ConnectionString="<%$ ConnectionStrings:PHConn %>"
SelectCommand="sp_getCartDetail" SelectCommandType="StoredProcedure"
runat="server">
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"_grdHistory"
Name
=
"CartID"
PropertyName
=
"SelectedValue"
Type
=
"Int32"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
Also what I would like to do is if column "Approved" is NULL/blank then change the 1st column to "Pending". Likewise with FedExTrack, I would like to show it as blank and not show the image. How can I go about accomplishing these two items. Below is the code I started with but when I added the DetailTable it broke my logic.
Sub
PopulateData()
Try
oConn.Open()
Dim
ocmd
As
New
SqlCommand(
"sp_getOrderHistoryFilter"
, oConn)
ocmd.CommandType = CommandType.StoredProcedure
With
ocmd.Parameters
.Add(
New
SqlParameter(
"@asi_num"
, Session(
"asi_num"
)))
.Add(
New
SqlParameter(
"@Date1"
, DBNull.Value))
.Add(
New
SqlParameter(
"@Date2"
, DBNull.Value))
.Add(
New
SqlParameter(
"@Area"
, DBNull.Value))
End
With
reader = ocmd.ExecuteReader()
Me
._grdHistory.DataSource = reader
Me
._grdHistory.DataBind()
Catch
ex
As
Exception
Finally
oConn.Close()
End
Try
End
Sub
Private
Sub
_grdHistory_ItemDataBound(sender
As
Object
, e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
_grdHistory.ItemDataBound
If
TypeOf
e.Item
Is
GridDataItem
Then
'This does not appear to be working at this time.
'Purpose is to display different text if the order has not been approved yet
'If e.Item.Cells(8).Text = " " Then
' e.Item.Cells(1).Text = "Pending"
' e.Item.Cells(1).Font.Italic = True
'End If
'If e.Item.Cells(6).Text = " " Then 'Hide Shipping if there is no data
' e.Item.Cells(7).Text = ""
'End If
End
If
End
Sub