For example, the three fields of the table Key1 Int, Key2 Int, Item Varchar (50) combined with primary key front desk:
<
ASP: DATAGRID
id
= "DataGrid1"
Runat
= "Server"
AutogenerateColumns
= "False"
Datakeyfield
= "DoubleKey"
>
<
Columns
>
<
ASP: BoundColumn
Datafield
= "item"
Headertext
= "item"
>
ASP: BoundColumn
>
<
ASP: ButtonColumn
CommandName
= "DEL"
TEXT
= "Delete"
>
ASP: ButtonColumn
>
Columns
>
ASP: DATAGRID
>
Backstage code:
Using
System;
Using
System.collections;
Using
System.componentmodel;
Using
System.data;
Using
System.data.sqlclient;
Using
System.drawing;
Using
System.Web;
Using
System.Web.SessionState;
Using
System.Web.ui;
Using
System.Web.ui.WebControls;
Using
System.Web.ui.htmlControls;
Namespace
9CBS2
{Public class WebForm20: System.Web.UI.Page {protected System.Web.UI.WebControls.DataGrid DataGrid1; private void Page_Load (object sender, System.EventArgs e) {if (IsPostBack!) {SetBind ();}} private void SetBind () {SqlConnection conn = new SqlConnection (System.Configuration.ConfigurationSettings.AppSettings [ "conn"]); SqlDataAdapter da = new SqlDataAdapter ( "select * from doublekey", conn); DataSet ds = new DataSet (); Da.Fill (DS); DataTable DT = DS.TABLES [0]; Datacolumn DC = New Datacolumn ("DoubleKey", TypeOf (String), "Key1 '#' key2"); dt.columns.add (DC) This.dataGrid1.datasource = DT; this.dataGrid1.database ();} Web Form Designer Generated Code #Region Web Form Designer Generated Code Override Protected Void OnInit (Eventargs E) {//// Codegen : This call is ASP.NET Web Form Designer is required. // InitializeComponent (); base.oninit (e);} / ** ////