⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 css-style-datagrid.aspx

📁 This is a book about vb.you could learn this from this book
💻 ASPX
字号:
<%@Page Language="VB"%>

<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.OleDb" %>

<%@ Register TagPrefix="wrox" TagName="connect" Src="..\global\connect-strings.ascx" %>
<%@ Register TagPrefix="wrox" TagName="getdataview" Src="..\global\get-dataview-control.ascx" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Using CSS to Add Style to a DataGrid</title>
<style type="text/css">
body {font-family:Tahoma,Arial,sans-serif; font-size:10pt}
input {font-family:Tahoma,Arial,sans-serif; font-size:9pt}
.heading {font-family:Tahoma,Arial,sans-serif; font-size:14pt; font-weight:bold}
.subhead {font-family:Tahoma,Arial,sans-serif; font-size:12pt; font-weight:bold; padding-bottom:5px}
.cite {font-family:Tahoma,Arial,sans-serif; font-size:8pt}
</style></head>
<body bgcolor="#ffffff">
<span class="heading">Using CSS to Add Style to a DataGrid</span><hr />
<!--------------------------------------------------------------------------->

<%'-- insert connection string script --%>
<wrox:connect id="ctlConnectStrings" runat="server"/>

<div id="outError" runat="server" />

<ASP:DataGrid id="MyDataGrid" runat="server"
  ShowHeader = "True"
  ShowFooter = "False"
  BackColor = "darkgray"
  BackImageUrl = "background.gif"
  ToolTip = "A List of Wrox Books"
  GridLines = "None"
  BorderStyle = "Solid"
  BorderColor = "black"
  BorderWidth = "3"
  CellPadding = "2"
  CellSpacing = "2"
  Font-Name = "Comic Sans MS"
  Font-Size = "10pt"
  Font-Bold = "True" >
    <HeaderStyle ForeColor = "blue" />
    <ItemStyle ForeColor = "red" />
    <AlternatingItemStyle ForeColor = "green" />
</ASP:DataGrid>

<!--------------------------------------------------------------------------->

<script language="vb" runat="server">

Sub Page_Load()

   'get connection string from ..\global\connect-strings.ascx user control
   Dim strConnect As String  = ctlConnectStrings.OLEDBConnectionString

   'create a SQL statement to select some rows from the database
   Dim strSelect As String
   strSelect = "SELECT * FROM BookList WHERE Title LIKE '%ASP%'"

   'create a variable to hold an instance of a DataReader object
   Dim objDataReader As OleDbDataReader

   Try

      'create a new Connection object using the connection string
      Dim objConnect As New OleDbConnection(strConnect)

      'open the connection to the database
      objConnect.Open()

      'create a new Command using the connection object and select statement
      Dim objCommand As New OleDbCommand(strSelect, objConnect)

      'execute the SQL statement against the command to get the DataReader
      objDataReader = objCommand.ExecuteReader()

    Catch objError As Exception

       'display error details
       outError.InnerHtml = "<b>* Error while accessing data</b>.<br />" _
           & objError.Message & "<br />" & objError.Source & "<p />"
       Exit Sub  ' and stop execution

    End Try

   'set the DataSource property of the DataGrid
   MyDataGrid.DataSource = objDataReader

   'and bind the control to the data
   MyDataGrid.DataBind()

End Sub

</script>

<!--------------------------------------------------------------------------->
<!-- #include file="..\global\foot.inc" -->
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -