How do I edit all rows in an ASP.NET ListView control at the same time?

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 can be in either C# or VB.NET.

Also, if possible, any sample code of saving each row's changes after all rows have been edited.


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") %>
                <asp:TextBox runat="server" ID="txtDepartmentName" Text='<%# Eval("dname") %>' Columns="30" />
            No departments found.
                    <th>Department ID</th>
                <asp:PlaceHolder runat="server" ID="plcItem" />

    ConnectionString="<%$ ConnectionStrings:HelpDeskConnectionString %>" 
    SelectCommand="SELECT * FROM [departments]" />

<asp:Button runat="server" ID="cmdSave" Text="Save Changes" OnClick="cmdSave_Click" />

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...

Need Your Help

Php Openssl not loading why?

php openssl

Hi guys I'm running a tweaked webmail application - however for some reason the openssl extension isn't loading - I've enabled it in the php.ini but when I run my application and check for loaded

Obfuscating database ID to customer facing number

php mysql obfuscation

I'm using mysql database auto-increment as an order ID. When I display the order ID to the user, I want to somehow mask/obfuscate it.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.