Data Binding Writing Process

xiaoxiao2021-03-06  65

Step 1: Mode Binding under Code Behind.

String connectionStr = "server = (local); database = pubs; user ID = sa; pw ="; // connection field

SqlConnection Con = New SqlConnection (ConnectStr); // Connect to the corresponding database with the connection field

SqlDataAdapter Adap = New SqldataAdapter ("SELECT TOP 5 * from Titles", CON // Generates data bridge objects

DataSet DS = New Dataset (); // Generate data group objects

Adap.Fill (DS, "Title"); // Put the data to the DS data group object

DataList1.datasource = DS.TABLES ["Titles"]; // Setting the data source

DataList1.databind (); // Bind to the DataList component

Step 2: Binding under HTML editing

<% # DataBinder.eval (Container.DataItem, "Title")%>

Step Description: Data -> Bridge -> Data Group -> Components

转载请注明原文地址:https://www.9cbs.com/read-89962.html

New Post(0)