I'm working on a WSS 3 site that has a ListViewWebpart displaying various columns.
I need to add a checkbox to each row and a button to the header that will perform a server side action for the selected rows.
Do I need to make my own custom webpart or can the ListViewWebpart support checkboxes?
Adding checkboxes to each row
I've found a post Checkbox in ListViewWebpart which suggests
...to add a checkbox, to select multiple listitem, in the custom list, declare a xml string as follows.
<Field Type="Computed" ReadOnly="TRUE" Name="ListItemSelection" DisplayName="Select" Sortable="FALSE" Filterable="FALSE" EnableLookup="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ListItemSelection">
<FieldRefs>
<FieldRef Name="ID" />
</FieldRefs>
<DisplayPattern>
<HTML><![CDATA[<input type="checkbox" ]]></HTML>
<HTML><![CDATA[LItemId="]]></HTML>
<Column Name="ID" HTMLEncode="TRUE" />
<HTML><![CDATA["/> ]]></HTML>
</DisplayPattern>
</Field>
and call the list.Fields.AddFieldAsXml(“xml string”);. Include this as a first column in your custom list’s view.
I'm assuming the latter part requires a SPList. E.g.
SPList list = SPContext.Current.Web.Lists["MyList"];
list.Fields.AddFieldAsXml(stringWithXmlFieldDefinition);
Adding a button to the header row
One option for the header button is a CustomAction. This should create a button in the toolbar.