ASP.NET的数据绑定学习

sub Page_Load(obj as Object, e as EventArgs) 'set up connection dim objConn as new OleDbConnection _ ("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=H:/ASPNET/data/banking.mdb") 'open connection dim objCmd as OleDbDataAdapter = new OleDbDataAdapter _ ("select * from tblUsers", objConn) 'fill dataset dim ds as DataSet = new DataSet() objCmd.Fill(ds, "tblUsers") 'select data view and bind to server control MyDataList.DataSource = ds.Tables("tblUsers"). _ DefaultView MyDataList.DataBind() end sub

 

 

 

<ASP:DataList id="MyDataList" RepeatColumns="2" RepeatDirection="Vertical" runat="server"> <ItemTemplate> <div style="padding:15,15,15,15;font-size:10pt; font-family:Verdana" mce_style="padding:15,15,15,15;font-size:10pt; font-family:Verdana"> <div style="font:12pt verdana;color:darkred" mce_style="font:12pt verdana;color:darkred"> <i><b><%# DataBinder.Eval(Container.DataItem, "FirstName")%>  <%# DataBinder.Eval(Container.DataItem, "LastName")%> </i></b> </div> <br> <b>Address: </b><%# DataBinder.Eval(Container.DataItem, _ "Address") %><br> <b>City: </b><%# DataBinder.Eval(Container.DataItem, _ "City")%><br> <b>State: </b><%# DataBinder.Eval _ (Container.DataItem, "State") %><br> <b>ZIP: </b><%# DataBinder.Eval _ (Container.DataItem, "Zip") %><br> <b>Phone: </b><%# DataBinder.Eval _ (Container.DataItem, "Phone") %><br> </div> </ItemTemplate> </ASP:DataList>

你可能感兴趣的:(server,object,asp.net,asp,div,dataset)