Tuesday, February 17, 2009

How to delete all items from a ListView using C#

To remove all listview items use the clear method

For example:

listView1.Clear();

will empty the listview

1 comments:

Anonymous said...

void BindData()
{
string[] Keys = new string[1];
Keys[0] = "IDOWNLOADID";
LvDownloads.DataKeyNames = Keys;
LvDownloads.DataSource = ObjDownloadBL.GetDownloads();
LvDownloads.DataBind();
}


protected void LvDownloads_ItemDeleting(object sender, ListViewDeleteEventArgs e)
{

//string DownloadId = int.Parse(e.CommandArgument.ToString());
ObjDownloadCon.IDOWNLOADID = int.Parse(this.LvDownloads.DataKeys[e.ItemIndex].Value.ToString());
ObjDownloadCon.sptype = "Delete";
ObjDownloadBL.Tbl_Download_Save_Update(ObjDownloadCon);
BindData();


}

kbAlertz.com :: Visual Studio 2005

kbAlertz.com :: Visual Studio 2008

kbAlertz.com :: Visual Basic 2005