The Visual Basic .Net Data Web Form page - Dataweb_personal.aspx, Text Codes
 
 
 

       
      Return

 


 
   

 The codes  corresponding ...
   
1-  Web.Config file, modify ...


  The
Data  Web Form to  work probably with connection,  add the folowing string in color  marroon
 
<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<system.web>

<!-- DYNAMIC DEBUG COMPILATION

Set compilation debug="true" to insert debugging symbols (.pdb information)

into the compiled page. Because this creates a larger file that executes

more slowly, you should set this value to true only when debugging and to

false at all other times. For more information, refer to the documentation about

debugging ASP.NET files.

-->

<compilation defaultLanguage="vb" debug="true" />

<!-- CUSTOM ERROR MESSAGES

Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.

Add <error> tags for each of the errors you want to handle.

"On" Always display custom (friendly) messages.

"Off" Always display detailed ASP.NET error information.

"RemoteOnly" Display custom (friendly) messages only to users not running

on the local Web server. This setting is recommended for security purposes, so

that you do not display application detail information to remote clients.

-->

<customErrors mode="RemoteOnly" />

<!-- AUTHENTICATION

This section sets the authentication policies of the application. Possible modes are "Windows",

"Forms", "Passport" and "None"

"None" No authentication is performed.

"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to

its settings for the application. Anonymous access must be disabled in IIS.

"Forms" You provide a custom form (Web page) for users to enter their credentials, and then

you authenticate them in your application. A user credential token is stored in a cookie.

"Passport" Authentication is performed via a centralized authentication service provided

by Microsoft that offers a single logon and core profile services for member sites.

-->

<authentication mode="Windows" />

 

<!-- AUTHORIZATION

This section sets the authorization policies of the application. You can allow or deny access

to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous

(unauthenticated) users.

-->

<authorization>

<allow users="*" /> <!-- Allow all users -->

<!-- <allow users="[comma separated list of users]"

roles="[comma separated list of roles]"/>

<deny users="[comma separated list of users]"

roles="[comma separated list of roles]"/>

-->

</authorization>

<!-- APPLICATION-LEVEL TRACE LOGGING

Application-level tracing enables trace log output for every page within an application.

Set trace enabled="true" to enable application trace logging. If pageOutput="true", the

trace information will be displayed at the bottom of each page. Otherwise, you can view the

application trace log by browsing the "trace.axd" page from your web application

root.

-->

<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />

 

<!-- SESSION STATE SETTINGS

By default ASP.NET uses cookies to identify which requests belong to a particular session.

If cookies are not available, a session can be tracked by adding a session identifier to the URL.

To disable cookies, set sessionState cookieless="true".

-->

<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

cookieless="false"

timeout="20"

/>

<identity impersonate="true"/>

<!-- GLOBALIZATION

This section sets the globalization settings of the application.

-->

<globalization requestEncoding="utf-8" responseEncoding="utf-8" />

</system.web>

</configuration>



2. 
The Web Form page -  Dataweb_personal.aspx , modify ...
    
   The text Code is red color, the codes added manuel ...
 

 
Public Class Dataweb_personal

Inherits System.Web.UI.Page


 

      Wwb Form Designer generated code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

If Session("mydatset") Is Nothing Then

Try

Me.LoadDataSet()

Me.masterDataGrid.SelectedIndex = -1

Catch eLoad As System.Exception

Me.Response.Write(eLoad.Message)

End Try

Session("mydataset") = Me.objDataweb_personaldset

With masterDataGrid

' Enable paging.

.AllowPaging = True

.PageSize = 5

End With

If Not Page.IsPostBack Then

FirstPage_Click(sender, e)

End If

Else

Me.objDataweb_personaldset = CType(Session("mydatset"), Dataweb_personaldset)

End If

End Sub

Public Sub LoadDataSet()

'Create a new dataset to hold the records returned from the call to FillDataSet.

'A temporary dataset is used because filling the existing dataset would

'require the databindings to be rebound.

Dim objDataSetTemp As Web_VBnet.Dataweb_personaldset

objDataSetTemp = New Web_VBnet.Dataweb_personaldset

Try

'Attempt to fill the temporary dataset.

Me.FillDataSet(objDataSetTemp)

Catch eFillDataSet As System.Exception

'Add your error handling code here.

Throw eFillDataSet

End Try

Try

'Empty the old records from the dataset.

objDataweb_personaldset.Clear()

'Merge the records into the main dataset.

objDataweb_personaldset.Merge(objDataSetTemp)

Catch eLoadMerge As System.Exception

'Add your error handling code here.

Throw eLoadMerge

End Try

End Sub

Public Sub FillDataSet(ByVal dataSet As Web_VBnet.Dataweb_personaldset)

'Turn off constraint checking before the dataset is filled.

'This allows the adapters to fill the dataset without concern

'for dependencies between the tables.

dataSet.EnforceConstraints = False

Try

'Open the connection.

Me.OleDbConnection1.Open()

'Attempt to fill the dataset through the OleDbDataAdapter1.

Me.OleDbDataAdapter1.Fill(dataSet)

Catch fillException As System.Exception

'Add your error handling code here.

Throw fillException

Finally

'Turn constraint checking back on.

dataSet.EnforceConstraints = True

'Close the connection whether or not the exception was thrown.

Me.OleDbConnection1.Close()

End Try

End Sub

' ***************************** Navigation ...

Private Sub FirstPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FirstPage.Click

masterDataGrid.CurrentPageIndex = 0

'Enabled buttons and bind the data

show_Button(masterDataGrid.CurrentPageIndex)

End Sub

'Enabled buttons and bind the data

Private Sub show_Button(ByVal vCurrentPage As Integer)

Dim vcpage As Integer = vCurrentPage + 1

Dim vPagecount As Integer

Select Case vCurrentPage

Case 0

FirstPage.Enabled = False

PreviousPage.Enabled = False

NextPage.Enabled = True

LastPage.Enabled = True

GoTo pt1

Case (masterDataGrid.PageCount - 1)

FirstPage.Enabled = True

PreviousPage.Enabled = True

NextPage.Enabled = False

LastPage.Enabled = False

GoTo pt1

Case Else

FirstPage.Enabled = True

PreviousPage.Enabled = True

NextPage.Enabled = True

LastPage.Enabled = True

End Select

pt1:

masterDataGrid.DataBind()

vPagecount = masterDataGrid.PageCount

Me.lbnavigation.Text = "Page : " + vcpage.ToString + " of " + vPagecount.ToString + " ............ info: Page size = 5"

End Sub

Private Sub PreviousPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreviousPage.Click

masterDataGrid.CurrentPageIndex = Math.Max(0, masterDataGrid.CurrentPageIndex - 1)

'Enabled buttons and bind the data

show_Button(masterDataGrid.CurrentPageIndex)

End Sub

Private Sub NextPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextPage.Click

masterDataGrid.CurrentPageIndex = Math.Min(masterDataGrid.PageCount - 1, masterDataGrid.CurrentPageIndex + 1)

'Enabled buttons and bind the data

show_Button(masterDataGrid.CurrentPageIndex)

End Sub

Private Sub LastPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LastPage.Click

masterDataGrid.CurrentPageIndex = masterDataGrid.PageCount - 1

'Enabled buttons and bind the data

show_Button(masterDataGrid.CurrentPageIndex)

End Sub

 

' ***************************** Edit, Update, Cancel

Private Sub masterDataGrid_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles masterDataGrid.EditCommand

Me.masterDataGrid.EditItemIndex = e.Item.ItemIndex

Me.masterDataGrid.DataBind()

End Sub

Private Sub masterDataGrid_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles masterDataGrid.CancelCommand

Me.masterDataGrid.EditItemIndex = -1

Me.masterDataGrid.DataBind()

End Sub

Private Sub masterDataGrid_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles masterDataGrid.UpdateCommand

Dim vfirstname, vname As String

Dim vsex, vcountry As String

' Gets the value of the key field of the row being updated

Dim key As String = Me.masterDataGrid.DataKeys(e.Item.ItemIndex).ToString()

' Gets get the value of the controls (textboxes) that the user

' updated. The DataGrid columns are exposed as the Cells collection.

' Each cell has a collection of controls. In this case, there is only one

' control in each cell -- a TextBox control. To get its value,

' you copy the TextBox to a local instance (which requires casting)

' and extract its Text property.

'

' The first column -- Cells(0) -- contains the Update and Cancel buttons.

Dim tb As TextBox

' Gets the value the TextBox control in the 2nd column

tb = CType(e.Item.Cells(1).Controls(0), TextBox)

vfirstname = tb.Text

' Gets the value the TextBox control in the 3th column

tb = CType(e.Item.Cells(2).Controls(0), TextBox)

vname = tb.Text

' Gets the value the TextBox control in the 4th column

tb = CType(e.Item.Cells(4).Controls(0), TextBox)

vsex = tb.Text

' Gets the value the TextBox control in the 5th column

tb = CType(e.Item.Cells(4).Controls(0), TextBox)

vcountry = tb.Text

' Finds the row in the dataset table that matches the

' one the user updated in the grid. This example uses a

' special Find method defined for the typed dataset, which

' returns a reference to the row.

Dim r As Dataweb_personaldset.personalRow

r = Me.objDataweb_personaldset.personal.FindBypersonal_id(key)

' Updates the dataset table.

r.first_name = vfirstname

r.name = vname

r.sex = vsex

r.country = vcountry

' Calls a OLE statement to update the database from the dataset

Me.OleDbDataAdapter1.Update(Me.objDataweb_personaldset)

' Takes the DataGrid row out of editing mode

Me.masterDataGrid.EditItemIndex = -1

' Refreshes the grid

Me.masterDataGrid.DataBind()

End Sub

 

End Class

   
  
 



 

      Return