<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <html> <script language="VB" runat="server"> Sub Page_Load(Sender As Object, E As EventArgs) ' Code is equivalent to Form_Load and Sub Main Dim DS As DataSet Dim MyConnection As SqlConnection Dim MyCommand As SqlDataAdapter MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsString")) MyCommand = New SqlDataAdapter("select Employee_ID, Employee_Surname, Employee_Forename from Employees", MyConnection) DS = New DataSet() MyCommand.Fill(DS, "Employees") DataGrid1.DataSource = DS.Tables("Employees").DefaultView DataGrid1.DataBind() End Sub </script> <body> <h3><font face="Verdana">Simple Stored Proc Select to a DataGrid Control</font></h3> <ASP:DataGrid id="DataGrid1" runat="server" Width="360" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding=3 CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" EnableViewState="false" /> </body> </html>
<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <html> <script language="VB" runat="server"> Sub Page_Load(Sender As Object, E As EventArgs) ' Code is equivalent to Form_Load and Sub Main Dim DS As DataSet Dim MyConnection As SqlConnection Dim MyCommand As SqlDataAdapter MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsString")) MyCommand = New SqlDataAdapter("select Employee_ID, Employee_Surname, Employee_Forename from Employees", MyConnection) DS = New DataSet() MyCommand.Fill(DS, "Employees") Repeater1.DataSource = DS.Tables("Employees").DefaultView Repeater1.DataBind() End Sub </script> <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"> <ASP:Repeater id="Repeater1" runat="server"> <HeaderTemplate> <table width="100%" style="font: 8pt verdana"> <tr style="background-color:DFA894"> <th>Employee ID</th> <th>Surname</th> <th>Forename</th> </tr> </HeaderTemplate> <ItemTemplate> <tr style="background-color:FFECD8"> <td><%# DataBinder.Eval(Container.DataItem, "Employee_ID") %></td> <td><%# DataBinder.Eval(Container.DataItem, "Employee_Surname") %></td> <td><%# DataBinder.Eval(Container.DataItem, "Employee_Forename") %></td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </ASP:Repeater> </Body> </HTML>
*Comments are the views of individuals, they may or may not be correct.All comments are reviewed and accepted or rejected.If you give an email address, you will be sent an email when someone makes a comment on this page.*