I would like to know how to put all of my ListView rows into edit mode at once. I am not looking for the traditional behavior of editing each row one at a time. The answer
Probably the easiest way is to just use the ListView's ItemTemplate, so in essence, the ListView is always in "edit mode":
<%# Eval("department_id") %>
No departments found.
Department ID
Name
You can then read the changed values when the user clicks the button:
protected void cmdSave_Click ( object sender, EventArgs e )
{
foreach ( ListViewItem item in lvwDepartments.Items )
{
if ( item.ItemType == ListViewItemType.DataItem )
{
TextBox txtDepartmentName = ( TextBox ) item.FindControl( "txtDepartmentName" );
// Process changed data here...
}
}
}