[thelist] Classic to Asp.NET 2.0

Rob Smith rob.smith at lexjet.com
Wed Jun 14 14:06:19 CDT 2006


As a learning exercise I'm taking our current homepage
http://www.lexjet.com and meticulously recreating it in ASP.NET 2.0,
line by line on my personal computer converted to a makeshift webserver
IIS 6. I'm using the master pages and xml sitemap files when needed. So
the particular "block" is the ad rotating thingy. The structure is a
table with two columns and five rows. The first column has a rowspan
equal to the number of ads with a maximum number of 5 and a minimum of
3. 

The rowspan is generated (in its current classic form):
SELECT count(adID) as rowspan FROM marketing Where publish <= '" &
date() & "' and expire > '" & date() & "' and preview = 0 order by
newid()

The value I assign is simply:
rowspan = LexJetAdsCount("rowspan").value

Then:
<table width="766" border="0" cellspacing="2">
  <tr valign="middle">
    <td width="560" 
	<%
		select case rowspan
			case "3"
				response.write "rowspan=""3"""
			case "4"
				response.write "rowspan=""4"""
			case "5"
				response.write "rowspan=""5"""
		end select
		%>
	
	>
...

Now. What I've gotten so far in Asp.net 2.0:

Sub Page_Load(ByVal sender As Object, _
                        ByVal e As System.EventArgs) Handles Me.Load
         If Not Page.IsPostBack Then
             'Start by determining the connection string value
             Dim connString As String = _
 
ConfigurationManager.ConnectionStrings("Server09").ConnectionString

             'Create a SqlConnection instance
             Using myConnection As New SqlConnection(connString)

                 'Specify the SQL query
                 Dim sql As String = "SELECT count(adID) as totals FROM
lexjet_marketing_new Where publish <= '" & Date.Now() & "' and expire >
'" & Date.Now() & "' and preview = 0 order by newid()"
                
                 'Create a SqlCommand instance
                 Dim myCommand As New SqlCommand(sql, myConnection)

                 'Get back a DataSet
                 Dim myDataSet As New DataSet

                 'Create a SqlDataAdapter instance
                 Dim myAdapter As New SqlDataAdapter(myCommand)
                 myAdapter.Fill(myDataSet)

                 'Bind the DataSet to the GridView
                 gvCustomers.DataSource = myDataSet
                 gvCustomers.DataBind()

                 'Close the connection
                 myConnection.Close()
             End Using
         End If
     End Sub

... which binds the data to a datagrid:
<asp:GridView runat="server" id="gvCustomers"></asp:GridView>

In the end I have the number I want, but it's now bound to that
datagrind...is and is not what I wanted.



Rob Smith
LexJet
rob.smith at lexjet.com
http://www.lexjet.com
(800)453-9538
(941)330-1210 Int'l
(941)330-1220 Fax
1680 Fruitville Road, 3rd Floor
Sarasota, FL 34236




More information about the thelist mailing list