GridView 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
GridView 클래스의 새 인스턴스를 초기화합니다.
public:
GridView();
public GridView ();
Public Sub New ()
예제
다음 예제에서는 동적으로 페이지에 컨트롤을 추가 GridView 하는 생성자를 사용 하는 방법을 보여 줍니다.
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Create a new GridView object.
GridView customersGridView = new GridView();
// Set the GridView object's properties.
customersGridView.ID = "CustomersGridView";
customersGridView.DataSourceID = "CustomersSource";
customersGridView.AutoGenerateColumns = true;
// Add the GridView object to the Controls collection
// of the PlaceHolder control.
GridViewPlaceHolder.Controls.Add(customersGridView);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>GridView Constructor Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>GridView Constructor Example</h3>
<asp:placeholder id="GridViewPlaceHolder"
runat="Server"/>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:sqldatasource id="CustomersSource"
selectcommand="Select [CustomerID], [CompanyName], [City] From [Customers]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Create a new GridView object.
Dim customersGridView As New GridView()
' Set the GridView object's properties.
customersGridView.ID = "CustomersGridView"
customersGridView.DataSourceID = "CustomersSource"
customersGridView.AutoGenerateColumns = True
' Add the GridView object to the Controls collection
' of the PlaceHolder control.
GridViewPlaceHolder.Controls.Add(customersGridView)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>GridView Constructor Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>GridView Constructor Example</h3>
<asp:placeholder id="GridViewPlaceHolder"
runat="Server"/>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:sqldatasource id="CustomersSource"
selectcommand="Select [CustomerID], [CompanyName], [City] From [Customers]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
설명
이 생성자의 새 인스턴스를 초기화 하는 데는 GridView 클래스입니다. 동적으로 추가 하는 GridView 컨트롤을 페이지, 새 GridView 개체 속성을 설정 하 고 추가한 다음이 Control.Controls 등의 컨테이너의 컬렉션 컨트롤 PlaceHolder합니다.