The problem is a fairly straight foward one, or so I thought. On the ItemDatabound event, I need to check the value of a certain column of the DataItem. If the data starts with "PTC" then I need to change the data for that column to read "New Order" instead. I thought I had it figured out, but it didn't work. I am assuming it's a simple fix, if someone can take a quick look at it. Here's the codebehind;
Private Sub rgPoOrders_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgPoOrders.ItemDataBound |
Dim TrackURL As String |
Dim Track As New PackageTrack |
If TypeOf e.Item Is GridDataItem Then |
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) |
Dim TrackNum As String = String.Empty |
Dim SubmittedBy As String = String.Empty |
'assign tracking number to variable |
If item.OwnerTableView Is rgPoOrders.MasterTableView Then |
TrackNum = item("cshortrmk").Text |
SubmittedBy = item("SubmittedBy").Text |
End If |
'Get URL for tracking number |
TrackURL = Track.Track(TrackNum) |
'Set Hyperlink variable/control, and URL to hyperlink control |
'NOTE: UPS has to open separate browser window. |
Dim TrackButton As HyperLink = DirectCast(item("hlTrackButton").Controls(0), HyperLink) |
TrackButton.NavigateUrl = TrackURL |
TrackButton.Target = "_blank" |
'Get Submitted by column, substitute .txt files for data |
If SubmittedBy.StartsWith("PTC") = True Then |
SubmittedBy = "New Order" |
End If |
End If |
End Sub |
Grid .aspx code:
<telerik:RadGrid ID="rgPoOrders" runat="server" DataSourceID="dsPurchaseOrders" |
GridLines="None" AllowFilteringByColumn="True" AllowPaging="True" |
AllowSorting="True" PageSize="25"> |
<MasterTableView ItemStyle-HorizontalAlign="Center" AutoGenerateColumns="False" |
Width="95%" DataKeyNames="cpono" DataSourceID="dsPurchaseOrders" |
GridLines="Horizontal" AlternatingItemStyle-HorizontalAlign="Center" |
HeaderStyle-HorizontalAlign="Center" PagerStyle-PageButtonCount="15"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px" /> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px" /> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridBoundColumn DataField="cpono" HeaderText="PO #" ReadOnly="True" |
SortExpression="cpono" UniqueName="cpono"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="cconfirmto" HeaderText="Submitted By" |
ReadOnly="true" UniqueName="SubmittedBy" > |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="DateOnly" DataType="System.DateTime" |
HeaderText="Date Submitted" SortExpression="DateOnly" UniqueName="DateOnly"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="cshortrmk" HeaderText="Tracking #" |
UniqueName="cshortrmk"> |
</telerik:GridBoundColumn> |
<telerik:GridHyperLinkColumn Text="Click Here To Track" HeaderText="" |
UniqueName="hlTrackButton"> |
</telerik:GridHyperLinkColumn> |
</Columns> |
<ItemStyle HorizontalAlign="Center" /> |
<AlternatingItemStyle HorizontalAlign="Center" /> |
<HeaderStyle HorizontalAlign="Center" /> |
</MasterTableView> |
</telerik:RadGrid> |