Web Matrix is an IDE (Integrated Development Enviroment), it is a tool
to help you create code, not a langauge.  You can develop ASP.NET code
using Visual Studio, Web Matrix or Notepad if you so desire.

The code you have supplied is the code behind for an ASP.NET page
written in VB.NET.  To use it as is, you need to create a companion
.aspx page that uses this class as its basis.

You can do that by including a page directive on top of the page....

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="ConfirmDelDG.aspx.vb"
Inherits="YourProjectNameorNamespaceHere.ConfirmDelDG"%>

You could also rewrite the code in a script block on the .aspx page.

HTH,

-- 
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com

On Wed, 15 Sep 2004 13:11:04 -0000, sas0riza <[EMAIL PROTECTED]> wrote:
> How do I rewrite the following in ASP.NET Web Matrix??
> 
> =====================================================================
> Imports System.Data
> Imports System.Data.SqlClient
> Imports System.Configuration
> Imports System.Web.UI.WebControls
> 
> Public Class ConfirmDelDG
>  Inherits System.Web.UI.Page
> 
>  Protected WithEvents dtgProducts As
> System.Web.UI.WebControls.DataGrid
>  Private strConnection As String = ConfigurationSettings.AppSettings
> ("NorthwindConnection")
>  Private strSql As String = "SELECT ProductID, ProductName,
> UnitPrice " _
>                           & "FROM Products WHERE CategoryID = 1"
>  Private objConn As SqlConnection
> 
>  Private Sub Page_Load(ByVal Sender As System.Object, ByVal E As
> System.EventArgs) Handles MyBase.Load
>    If Not IsPostBack Then
>      BindTheGrid()
>    End If
>  End Sub
> 
>  Private Sub BindTheGrid()
>    Connect()
>    Dim adapter As New SqlDataAdapter(strSql, objConn)
>    Dim ds As New DataSet()
>    adapter.Fill(ds, "Products")
>    Disconnect()
> 
>    dtgProducts.DataSource = ds.Tables("Products")
>    dtgProducts.DataBind()
>  End Sub
> 
>  Private Sub Connect()
>    If objConn Is Nothing Then
>      objConn = New SqlConnection(strConnection)
>    End If
> 
>    If objConn.State = ConnectionState.Closed Then
>      objConn.Open()
>    End If
>  End Sub
> 
>  Private Sub Disconnect()
>    objConn.Dispose()
>  End Sub
> 
>  Private Sub dtgProducts_ItemDataBound (ByVal sender As
> System.Object, _
>    ByVal e As DataGridItemEventArgs) Handles
> dtgProducts.ItemDataBound
> 
>    Dim btn As Button
>    If e.Item.ItemType = ListItemType.Item or e.Item.ItemType =
> ListItemType.AlternatingItem Then
>      btn = CType(e.Item.Cells(0).FindControl("btnDelete"), Button)
>      btn.Attributes.Add("onclick", "return confirm_delete();")
>    End If
> 
>  End Sub
> 
>  Public Sub Delete_Row(ByVal Sender As Object, ByVal E As
> DataGridCommandEventArgs)
> 
>    ' Retrieve the ID of the product to be deleted
>    Dim ProductID As system.Int32 = System.Convert.ToInt32
> (E.Item.Cells(0).Text)
> 
>    dtgProducts.EditItemIndex = -1
> 
>    ' Create and load a DataSet
>    Connect()
>    Dim adapter As New SqlDataAdapter(strSql, objConn)
>    Dim ds As New DataSet()
>    adapter.Fill(ds, "Products")
>    Disconnect()
> 
>    ' Mark the product as Deleted in the DataSet
>    Dim tbl As DataTable = ds.Tables("Products")
>    tbl.PrimaryKey = New DataColumn() _
>                     { _
>                       tbl.Columns("ProductID") _
>                     }
>    Dim row As DataRow = tbl.Rows.Find(ProductID)
>    row.Delete()
> 
>    ' Reconnect the DataSet and delete the row from the database
>    '-----------------------------------------------------------
>    ' Following section commented out for demonstration purposes
>    'Dim cb As New SqlCommandBuilder(adapter)
>    'Connect()
>    'adapter.Update(ds, "Products")
>    'Disconnect()
>    '-----------------------------------------------------------
>    ' Display remaining rows in the DataGrid
>    dtgProducts.DataSource = ds.Tables("Products")
>    dtgProducts.DataBind()
> 
>  End Sub
> 
> End Class
> ===================================================================
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to