DataGrid 控件呈现表格式数据绑定网格。该控件允许您定义各种类型的列,这些列有的用于控制网格的单元格内容的布局,如绑定列和模板列;有的用于添加特定功能,如编辑按钮列和超级链接列等。该控件还支持各种用于在数据中进行分页的选项。

<asp:DataGrid
????AccessKey="string"
????AllowCustomPaging="True|False"
????AllowPaging="True|False"
????AllowSorting="True|False"
????AutoGenerateColumns="True|False"
????BackColor="color name|#dddddd"
????BackImageUrl="uri"
????BorderColor="color name|#dddddd"
????BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
        Inset|Outset"
????BorderWidth="size"
????Caption="string"
????CaptionAlign="NotSet|Top|Bottom|Left|Right"
????CellPadding="integer"
????CellSpacing="integer"
????CssClass="string"
????DataKeyField="string"
????DataMember="string"
????DataSource="string"
????DataSourceID="string"
????EditItemIndex="integer"
????Enabled="True|False"
????EnableTheming="True|False"
????EnableViewState="True|False"
????Font-Bold="True|False"
????Font-Italic="True|False"
????Font-Names="string"
????Font-Overline="True|False"
????Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
        Large|X-Large|XX-Large"
????Font-Strikeout="True|False"
????Font-Underline="True|False"
????ForeColor="color name|#dddddd"
????GridLines="None|Horizontal|Vertical|Both"
????Height="size"
????HorizontalAlign="NotSet|Left|Center|Right|Justify"
????ID="string"
????OnCancelCommand="CancelCommand event handler"
????OnDataBinding="DataBinding event handler"
????OnDeleteCommand="DeleteCommand event handler"
????OnDisposed="Disposed event handler"
????OnEditCommand="EditCommand event handler"
????OnInit="Init event handler"
????OnItemCommand="ItemCommand event handler"
????OnItemCreated="ItemCreated event handler"
????OnItemDataBound="ItemDataBound event handler"
????OnLoad="Load event handler"
????OnPageIndexChanged="PageIndexChanged event handler"
????OnPreRender="PreRender event handler"
????OnSelectedIndexChanged="SelectedIndexChanged event handler"
????OnSortCommand="SortCommand event handler"
????OnUnload="Unload event handler"
????OnUpdateCommand="UpdateCommand event handler"
????PageSize="integer"
????runat="server"
????SelectedIndex="integer"
????ShowFooter="True|False"
????ShowHeader="True|False"
????SkinID="string"
????Style="string"
????TabIndex="integer"
????ToolTip="string"
????UseAccessibleHeader="True|False"
????Visible="True|False"
????Width="size"
>
????????<AlternatingItemStyle />
????????<Columns>
????????????????<asp:BoundColumn
????????????????????DataField="string"
????????????????????DataFormatString="string"
????????????????????FooterText="string"
????????????????????HeaderImageUrl="uri"
????????????????????HeaderText="string"
????????????????????ReadOnly="True|False"
????????????????????SortExpression="string"
????????????????????Visible="True|False"
>
????????????????????????<FooterStyle />
????????????????????????<HeaderStyle />
????????????????????????<ItemStyle />
????????????????</asp:BoundColumn>
????????????????<asp:ButtonColumn
????????????????????ButtonType="LinkButton|PushButton"
????????????????????CausesValidation="True|False"
????????????????????CommandName="string"
????????????????????DataTextField="string"
????????????????????DataTextFormatString="string"
????????????????????FooterText="string"
????????????????????HeaderImageUrl="uri"
????????????????????HeaderText="string"
????????????????????SortExpression="string"
????????????????????Text="string"
????????????????????ValidationGroup="string"
????????????????????Visible="True|False"
>
????????????????????????<FooterStyle />
????????????????????????<HeaderStyle />
????????????????????????<ItemStyle />
????????????????</asp:ButtonColumn>
????????????????<asp:EditCommandColumn
????????????????????ButtonType="LinkButton|PushButton"
????????????????????CancelText="string"
????????????????????CausesValidation="True|False"
????????????????????EditText="string"
????????????????????FooterText="string"
????????????????????HeaderImageUrl="uri"
????????????????????HeaderText="string"
????????????????????SortExpression="string"
????????????????????UpdateText="string"
????????????????????ValidationGroup="string"
????????????????????Visible="True|False"
>
????????????????????????<FooterStyle />
????????????????????????<HeaderStyle />
????????????????????????<ItemStyle />
????????????????</asp:EditCommandColumn>
????????????????<asp:HyperLinkColumn
????????????????????DataNavigateUrlField="string"
????????????????????DataNavigateUrlFormatString="string"
????????????????????DataTextField="string"
????????????????????DataTextFormatString="string"
????????????????????FooterText="string"
????????????????????HeaderImageUrl="uri"
????????????????????HeaderText="string"
????????????????????NavigateUrl="uri"
????????????????????SortExpression="string"
????????????????????Target="string|_blank|_parent|_search|_self|_top"
????????????????????Text="string"
????????????????????Visible="True|False"
>
????????????????????????<FooterStyle />
????????????????????????<HeaderStyle />
????????????????????????<ItemStyle />
????????????????</asp:HyperLinkColumn>
????????????????<asp:TemplateColumn
????????????????????FooterText="string"
????????????????????HeaderImageUrl="uri"
????????????????????HeaderText="string"
????????????????????SortExpression="string"
????????????????????Visible="True|False"
>
????????????????????????????<FooterStyle />
????????????????????????????<HeaderStyle />
????????????????????????????<ItemStyle />
????????????????????????<EditItemTemplate>
                            <!-- child controls -->
????????????????????????</EditItemTemplate>
????????????????????????<FooterTemplate>
                            <!-- child controls -->
????????????????????????</FooterTemplate>
????????????????????????<HeaderTemplate>
                            <!-- child controls -->
????????????????????????</HeaderTemplate>
????????????????????????<ItemTemplate>
                            <!-- child controls -->
????????????????????????</ItemTemplate>
????????????????</asp:TemplateColumn>
????????</Columns>
????????<EditItemStyle />
????????<FooterStyle />
????????<HeaderStyle />
????????<ItemStyle />
????????<PagerStyle
????????????BackColor="color name|#dddddd"
????????????BorderColor="color name|#dddddd"
????????????BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
                Groove|Ridge|Inset|Outset"
????????????BorderWidth="size"
????????????CssClass="string"
????????????Font-Bold="True|False"
????????????Font-Italic="True|False"
????????????Font-Names="string"
????????????Font-Overline="True|False"
????????????Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
                Medium|Large|X-Large|XX-Large"
????????????Font-Strikeout="True|False"
????????????Font-Underline="True|False"
????????????ForeColor="color name|#dddddd"
????????????Height="size"
????????????HorizontalAlign="NotSet|Left|Center|Right|Justify"
????????????Mode="NextPrev|NumericPages"
????????????NextPageText="string"
????????????OnDisposed="Disposed event handler"
????????????PageButtonCount="integer"
????????????Position="Bottom|Top|TopAndBottom"
????????????PrevPageText="string"
????????????VerticalAlign="NotSet|Top|Middle|Bottom"
????????????Visible="True|False"
????????????Width="size"
????????????Wrap="True|False"
????????/>
????????<SelectedItemStyle />
</asp:DataGrid>

Expand 图像备注

Expand 图像DataGridColumn 基本属性

Expand 图像BoundColumn 属性

Expand 图像ButtonColumn 属性

Expand 图像TemplateColumn 属性

Expand 图像HyperLinkColumn 属性

Expand 图像EditCommandColumn 属性

Expand 图像样式属性

Expand 图像示例

Expand image请参见