Remove an item from Listview

I have a listview populated by session state
session("test")
I would like to remove a row from  listview and datatable. thanks
zachvaldezAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
What is the condition to remove the item?

Dim dt As DataTable = Session("test")
dt.Rows(0).Delete()

Listview1.DataSource = dt
Listview1.DataBind()
0
 
CodeCruiserCommented:
Based on what condition? Is Session("test") a datatable?
0
 
zachvaldezAuthor Commented:
yes
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
zachvaldezAuthor Commented:
<td>
                        <asp:LinkButton ID="EditButton" runat="Server" Text="Edit" CommandName="Edit" />
                    </td>
                    <td>
                        <asp:LinkButton ID="LinkButton1" runat="Server" Text="Delete" CommandName="Delete" />
                    </td>

I think the code has to go to the Listview1_itemcommand

also Datakeys = "rowID"

I
0
 
zachvaldezAuthor Commented:
Hi ,
It deletes but cannot find the index or the row...
This..dt.Rows(0).Delete()
only deletes the first item which has the index(0) but not the row that is selected.

thanks
0
 
zachvaldezAuthor Commented:
I found the answer to get the index..

dt.Rows(e.Item.DataItemIndex).Delete()>>>gets to the point

BTW how does Edit work?
Should I be able to edit in place in the listview or assign the values in the form?
I put additional points here

Thanks
0
 
zachvaldezAuthor Commented:
Great! Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.