hehe.. jah det er svært at koncentrere sig i den her varme :)..
Men her er hele siden :)
----------------------------
<%@ Page Language="VB" debug="true" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.Odbc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="
http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mindpeople Link Collection</title>
<link href="/links/stylesheet.css" rel="stylesheet" type="text/css" media="screen" />
<script runat="server" language="vb">
' Retrieve data for page '
sub Page_Load(s As object, e As EventArgs)
if not IsPostBack then
Dim strConn As String = "Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=xxxxx; uid=xxxxx; pwd=xxxxx; option=3"
Dim objConn As OdbcConnection = New OdbcConnection(strConn)
objConn.Open()
' Get Links data '
Dim ddlCategory As String
if Request.QueryString("category") > "" then
ddlCategory = Request.QueryString("category")
else
ddlCategory = "cat01"
end if
Dim sqlTextLinks As String = "SELECT * FROM links WHERE links_Category='" & ddlCategory & "' ORDER BY links_Title"
Dim objDALinks As OdbcDataAdapter = New OdbcDataAdapter(sqlTextLinks, objConn)
Dim objDSLinks As New DataSet()
objDALinks.Fill (objDSLinks, "Links")
dgLinks.DataSource = objDSLinks
dgLinks.DataBind()
objConn.Close()
end if
end sub
' Edit database entries '
sub dg_Edit(s As Object, e As DataGridCommandEventArgs)
dgLinks.EditItemIndex = e.Item.ItemIndex
dgLinks.DataBind
end sub
sub dg_Cancel(s As Object, e As DataGridCommandEventArgs)
dgLinks.EditItemIndex = -1
dgLinks.DataBind()
end sub
sub dg_Update(s As Object, e As DataGridCommandEventArgs)
Dim intLinkID As Integer = dgLinks.DataKeys(e.Item.ItemIndex)
Dim strLinkText As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Dim strCmd As String = "UPDATE links SET links_Text=@LinkText WHERE links_ID=@LinkID"
Dim strConn As String = "Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=xxxxx; uid=xxxxx; pwd=xxxxx; option=3"
Dim objConn As OdbcConnection = New OdbcConnection(strConn)
Dim objCmd As OdbcCommand = New OdbcCommand(strCmd, objConn)
objCmd.Parameters.Add("@LinkID", OdbcType.NVarChar)
objCmd.Parameters("@LinkID").Value = intLinkID
objCmd.Parameters.Add("@LinkText", OdbcType.NVarChar)
objCmd.Parameters("@LinkText").Value = strLinkText
' objCmd.Parameters.Add("@LinkID", intLinkID) '
' objCmd.Parameters.Add("@LinkText", strLinkText) '
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
dgLinks.EditItemIndex = -1
dgLinks.DataBind
end sub
' Redirect Page '
sub subRedirPage(s As Object, e As EventArgs)
Dim strCategory As String = "?category=" & Server.UrlEncode(selectCategory.SelectedItem.Value)
Response.Redirect("
http://www.mindpeople.dk/links/index.aspx" & strCategory)
end sub
</script>
</head>
<body>
<!-- Topsite -->
<!--#include virtual="/links/includes/topsite.aspx" -->
<!-- Content -->
<form runat="server">
<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="600" align="right" valign="bottom">
<asp:Dropdownlist id="selectCategory" CssClass="selectbox" AutoPostBack="true" runat="server">
<asp:ListItem Text="Inspiration" Value="cat01" />
<asp:ListItem Text="Stock Photos" Value="cat02" />
<asp:ListItem Text="Tutorials" Value="cat03" />
</asp:Dropdownlist>
<asp:Button id="btnGoToPage" Text=" Go! " CssClass="selectbox" OnClick="subRedirPage" runat="server" />
</td>
</tr>
</table>
<table width="600" height="10" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td> </td>
</tr>
</table>
<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="600" align="left" valign="top">
<p>
<asp:DataGrid
ID="dgLinks"
runat="server"
AutoGenerateColumns="false"
CellSpacing="2"
CellPadding="5"
BorderWidth="0"
DataKeyField="links_ID"
OnEditCommand="dg_Edit"
OnCancelCommand="dg_Cancel"
OnUpdateCommand="dg_Update">
<headerstyle Font-Name="Verdana" Font-Size="10px" ForeColor="#FFFFFF" BackColor="#9B0000" Font-Bold="true" />
<itemstyle Font-Name="Verdana" Font-Size="10px" ForeColor="#333333" BackColor="#DDDDDD" />
<alternatingitemstyle Font-Name="Verdana" Font-Size="10px" ForeColor="#333333" BackColor="#BFBFBF" />
<columns>
<asp:HyperLinkColumn
DataTextField="links_Title"
DataNavigateUrlField="links_link"
DataNavigateUrlFormatString="
http://{0}" DataTextFormatString="<span class='bodytext_link_red'>{0}</span>"
Target="_blank"
HeaderText="Site">
<headerstyle Width="150px" />
</asp:HyperLinkColumn>
<asp:BoundColumn
DataField="links_Text"
HeaderText="Description">
<headerstyle Width="350px" />
</asp:BoundColumn>
<asp:EditCommandColumn
EditText="Edit"
CancelText="Cancel"
UpdateText="Update">
<headerstyle Width="100px" />
</asp:EditCommandColumn>
</columns>
</asp:DataGrid>
</p>
</td>
</tr>
</table>
</form>
</body>
</html>