This is a migrated thread and some comments may be shown as answers.

Set ListView in EditMode via a control outisde the Listview

2 Answers 39 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 13 Nov 2013, 06:05 PM
Good day, I'm merely trying to set the ListView in EditMode via the use of a radButton_click but nothing I've tried so far has worked.

<
telerik:RadListView ID="CommitmentsListView" runat="server" DataKeyNames="AgreementID" ItemPlaceholderID="CommitmentsContainer"
                                                                                EnableViewState="true" InsertItemPosition="FirstItem" >
    <LayoutTemplate>
        <div style="min-height: 100px">
            <asp:PlaceHolder runat="server" ID="CommitmentsContainer" />
        </div>
    </LayoutTemplate>
    <ItemTemplate>
        <div style="text-align:right;padding-right:2px;">
            <asp:Label ID="lblCommitmentNumber" runat="server" Text="Commitment Number:" Font-Bold="true" Style="margin-top:5px;font-size:0.75em;"></asp:Label>
            <br />
            <asp:Label ID="lblPurchaseOrder" runat="server" Text="Purchase Order:" Font-Bold="true" Style="margin-top:5px;font-size:0.75em;"></asp:Label>
        </div>
    </ItemTemplate>
    <EditItemTemplate>
        <div style="text-align:right;padding-right:2px;">
            <asp:Label ID="lblCommitmentNumber" runat="server" Text="Commitment Number:" Font-Bold="true" Style="margin-top:5px;font-size:0.75em;"></asp:Label>
            <br />
                    <telerik:RadComboBox ID="PurchaseOrder" runat="server" HighlightTemplatedItems="true" Style="font-weight:Bold;" 
                                    DataTextField="PurchaseOrder" DataValueField="PurchaseOrder"  Width="80px" AutoPostBack="true" >
                    </telerik:RadComboBox>                   
        </div>
 
    </EditItemTemplate>
 </telerik:RadListView>
 
<telerik:RadButton ID="EditButton" runat="server" Text='Edit' CommandName="Edit" CausesValidation="false">
    <Icon PrimaryIconCssClass="rbEdit" PrimaryIconLeft="4" PrimaryIconTop="4"></Icon>
</telerik:RadButton>
Private Sub CommitmentsListView_NeedDataSource(sender As Object, e As RadListViewNeedDataSourceEventArgs) Handles CommitmentsListView.NeedDataSource
 
    Dim myList As New List(Of BudgetCommitment)
    myList.Add(New BudgetCommitment("001AR1101-E", 2015))
 
    CommitmentsListView.DataSource = myList.ToList
 
End Sub
 
Private Sub EditButton_Click(sender As Object, e As EventArgs) Handles EditButton.Click
 
End Sub

2 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 13 Nov 2013, 06:11 PM
After all this testing, two minutes after I posted, I got the below to work.

Private Sub EditButton_Click(sender As Object, e As EventArgs) Handles EditButton.Click
    CommitmentsListView.IsItemInserted = False
    For i = 0 To CommitmentsListView.PageSize - 1
        CommitmentsListView.EditIndexes.Add(i)
    Next
    CommitmentsListView.Rebind()
End Sub



0
Eyup
Telerik team
answered on 18 Nov 2013, 02:42 PM
Hi Tim,

I am glad you have managed to find a solution yourself.
You can also try:
RadListView1.EditIndexes.AddRange(Enumerable.Range(0, RadListView1.Items.Count));

Please let us know if new questions arise.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ListView
Asked by
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or