Forum Moderators: open
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table cellspacing="5">
</HeaderTemplate>
<ItemTemplate>
<tr valign="middle">
<td width="80px">
<asp:Button ID="AddButton" runat="server" Text="Add" CommandName="Add" CausesValidation="True" ValidationGroup ="bulkValidation" />
<asp:Button ID="RemoveBtn" runat="server" Text="Delete" CommandName="Remove" CausesValidation="false"
Visible="false" />
</td>
<td width="175px">
<telerik:RadComboBox ID="RadSearchComboBox" runat="server" Width="150px" Height="175px" ValidationGroup ="bulkValidation"
AllowCustomText="True" ShowToggleImage="False" OnSelectedIndexChanged="itemChanged"
ShowMoreResultsBox="true" EnableLoadOnDemand="True" Skin="Telerik" MarkFirstMatch="True"
OnItemsRequested="loadSearch" EnableVirtualScrolling="true" EmptyMessage="Enter Part Number"
ErrorMessage="Value not Found" AutoPostBack="False" OnClientItemsRequested="OnClientItemsRequested">
<CollapseAnimation Duration="100" Type="OutQuint" />
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ValidationGroup ="bulkValidation"
ControlToValidate="RadSearchComboBox" />
</td>
<td width="45px">
<telerik:RadNumericTextBox ID="QtyTextBox" runat="server" MaxLength="3" MaxValue="999" ValidationGroup ="bulkValidation"
MinValue="1" NumberFormat-DecimalDigits="0" ShowSpinButtons="false" Type="Number"
Width="20px" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ValidationGroup ="bulkValidation"
ControlToValidate="QtyTextBox" />
</td>
<td class="H2Internal">
<asp:Label CssClass ="H2Internal" id="partName" runat="server" Text=""></asp:Label>
<asp:Label CssClass ="H2Internal" id="price" runat="server" Text=""></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Here is the vb
Protected Sub rptrCommand(ByVal sender As Object, ByVal e As RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
Dim index As Integer
index = e.Item.ItemIndex
If e.CommandName = "Remove" Then
bulkItems.RemoveAt(index)
Me.Repeater1.DataSource = bulkItems
Me.Repeater1.DataBind()
ElseIf e.CommandName = "Add" Then
Page.Validate()
If Page.IsValid() Then
Me.bulkItems.Add(New bulkOrderItem())
Me.Repeater1.DataSource = bulkItems
'this is a static label outside of the repeater
'it sets to test when the user clicks to add
msgLabel.Text = "test"
'the two labels
Dim tempPartLabel As New Label
tempPartLabel = Me.Repeater1.Items(index).FindControl("partName")
Dim tempPriceLabel As New Label
tempPriceLabel = Me.Repeater1.Items(index).FindControl("price")
Me.Repeater1.DataBind()
Me.Repeater1.Items(index).FindControl("AddButton").Visible = False
Me.Repeater1.Items(index).FindControl("RemoveBtn").Visible = True
'right now I am just trying to set them to static data
'however this will not work.
tempPartLabel.Text = "testing"
tempPriceLabel.Text = "price testing"
End If
Panel1.Update()
End If
End Sub
Does anyone know what I am doing wrong? Thanks,
Dim connString As String = System.Configuration.ConfigurationManager.ConnectionStrings("orthmanConnectionString").ToString
Dim myConnection As New Data.SqlClient.SqlConnection(connString)
Dim strSQL = "getPartInfo"
Dim selectCommand As New Data.SqlClient.SqlCommand(strSQL, myConnection)
Dim userReader As SqlDataReader
Try
selectCommand.CommandType = CommandType.StoredProcedure
selectCommand.Parameters.AddWithValue("@partId", e.Text)
myConnection.Open()
userReader = selectCommand.ExecuteReader()
userReader.Read()
If Not (IsDBNull(userReader(0))) Then
partLabel.Text = "Part Name: <span class='MainText'>" & userReader(0) & "</span>"
Else
partLabel.Text = "Part Name: <span class='MainText'>No information</span>"
End If
If Not (IsDBNull(userReader(1))) Then
priceLabel.Text = "Price: <span class='MainText'>" & FormatCurrency(userReader(1)) & "</span>"
Else
priceLabel.Text = "Price: <span class='MainText'>No information</span>"
End If
userReader.Close()
Catch ex As Exception
Me.msgLabel.Text = ex.ToString
'Me.msgLabel.Text = "Oops, there was an error in retrieving the part information. " & _
' "Try reloading the page (ctrl+f5) and entering the information again. Please contact the system " & _
' "administrator if the problem persists"
Finally
myConnection.Close()
End Try
End Sub
Aspx
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table cellspacing="5">
</HeaderTemplate>
<ItemTemplate>
<tr valign="middle">
<td width="80px">
<asp:Button ID="AddButton" runat="server" Text="Add" CommandName="Add" CausesValidation="True" ValidationGroup ="bulkValidation" />
<asp:Button ID="RemoveBtn" runat="server" Text="Delete" CommandName="Remove" CausesValidation="false"
Visible="false" />
</td>
<td width="175px">
<telerik:RadComboBox ID="RadSearchComboBox" runat="server" Width="150px" Height="175px" ValidationGroup ="bulkValidation"
onselectedindexchanged="itemChanged"
AllowCustomText="True" ShowToggleImage="False"
ShowMoreResultsBox="true" EnableLoadOnDemand="True" Skin="Telerik" MarkFirstMatch="True"
OnItemsRequested="loadSearch" EnableVirtualScrolling="true" EmptyMessage="Enter Part Number"
ErrorMessage="Value not Found" AutoPostBack="True" OnClientItemsRequested="OnClientItemsRequested">
<CollapseAnimation Duration="100" Type="OutQuint" />
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ValidationGroup ="bulkValidation"
ControlToValidate="RadSearchComboBox" />
</td>
<td width="45px">
<telerik:RadNumericTextBox ID="QtyTextBox" runat="server" MaxLength="3" MaxValue="999" ValidationGroup ="bulkValidation"
MinValue="1" NumberFormat-DecimalDigits="0" ShowSpinButtons="false" Type="Number"
Width="20px" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ValidationGroup ="bulkValidation"
ControlToValidate="QtyTextBox" />
</td>
<td class="H2Internal">
<asp:Label CssClass ="H2Internal" id="partName" runat="server"></asp:Label>
<asp:Label CssClass ="H2Internal" id="price" runat="server"></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I hope that helps someone else because it took me forever to figure that out.