I have looked at some helpful tips generated based on Title but none has helped with the issue that I am having.
When we run the code below, we keep getting error: Conversion from type 'DataRowView' to type 'String' is not valid
I am lost as to what to try to fix this problem.
Any ideas?
Protected Sub OnItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
'Find the DropDownList in the Repeater Item.
Dim PurchaseDate As String = (TryCast(e.Item.FindControl("PurchaseDate"), TextBox)).Text
Dim hfAsset As HiddenField = (TryCast(e.Item.FindControl("hfAsset"), HiddenField))
Dim ddlAsset As DropDownList = (TryCast(e.Item.FindControl("ddlAsset"), DropDownList))
ddlAsset.DataSource = GetData("SELECT DISTINCT AssetID, Asset FROM AssetTable")
ddlAsset.DataTextField = "Asset"
ddlAsset.DataValueField = "AssetID"
ddlAsset.DataBind()
ddlAsset.ClearSelection()
If ddlAsset.Items.FindByText(hfAsset.Value) IsNot Nothing Then
ddlAsset.Items.FindByText(hfAsset.Value).Selected = True
End If
End If
End Sub
<HeaderTemplate>
<table border="1" style="background-color:White; width:90%; border-color:lavender; border-collapse:collapse;">
<tr>
<th style="text-align:left;">
Assets </th>
<th style="text-align:left;">
Purchase Date </th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:DropDownList ID="ddlToiletGPF" class="ChangeWidth" AppendDataBoundItems="true" runat="server" AutoPostBack="true" >
<asp:ListItem Text="Select" selected="True" Value="" />
</asp:DropDownList>
<asp:HiddenField ID="hfAsset" runat="server" Value='<%# Eval(Container.DataItem, "Asset") %>' />
</td>
<td>
<asp:TextBox ID="PurchaseDate" style="width:200px" Text='<%# DataBinder.Eval(Container.DataItem, "PurchaseDate") %>' DataFormatString="{0:MM/dd/yyyy}" runat="server"></asp:TextBox><ajax:CalendarExtender ID="pruchaseDte" runat="server" TargetControlID="PurchaseDate" Format="MM/dd/yyyy" ViewStateMode="Enabled" />
</td>
</tr>
</ItemTemplate>
Error is on this line:
<asp:HiddenField ID="hfAsset" runat="server" Value='<%# Eval(Container.DataItem, "Asset") %>' />
Thanks in advance for your assistance