User Tools

Site Tools


notes:sharepoint2010:gridview

SPGridView in SharePoint 2010

Example #1:

<SharePoint:SPGridView id="SPGridView1" AutoGenerateColumns="false" Width="800" 
    UseAccessibleHeader="False" runat="server">
    <HeaderStyle HorizontalAlign="Center" ForeColor="Navy" Font-Bold="true" />
    <AlternatingRowStyle BackColor="WhiteSmoke" />
    <Columns>
        <SharePoint:SPBoundField DataField="EmailDateTime" HeaderText="Date/Time"></SharePoint:SPBoundField>
        <SharePoint:SPBoundField DataField="EmailSubject" HeaderText="Subject"></SharePoint:SPBoundField>
        <SharePoint:SPBoundField DataField="SenderEmail" HeaderText="Sender"></SharePoint:SPBoundField>
        <SharePoint:SPBoundField DataField="ToEmails" HeaderText="To"></SharePoint:SPBoundField>
        <SharePoint:SPBoundField DataField="CCEmails" HeaderText="CC"></SharePoint:SPBoundField>
        <SharePoint:SPBoundField DataField="EmailBody" HeaderText="Email"></SharePoint:SPBoundField>
    </Columns>
</SharePoint:SPGridView>

Example #2:

<SharePoint:SPGridView id="SPGridView1" runat="server" AutoGenerateColumns="false">
    <HeaderStyle HorizontalAlign="Center" ForeColor="Navy" Font-Bold="true" />
    <Columns>
        <asp:TemplateField HeaderText="Title" SortExpression="Title">
            <ItemTemplate>
            <asp:HyperLink ID="hypTitle" 
                NavigateUrl='<%# Eval("WebUrl")%>' Text='<%# Eval("Title")%>' runat="server" />
            </ItemTemplate>
        </asp:TemplateField>
 
        <SharePoint:SPBoundField DataField="Desc" HeaderText="Description"></SharePoint:SPBoundField>
        <SharePoint:SPBoundField DataField="Abbr" HeaderText="Abbreviation"></SharePoint:SPBoundField>
    </Columns>
</SharePoint:SPGridView>
notes/sharepoint2010/gridview.txt · Last modified: 2020/08/26 (external edit)