Académique Documents
Professionnel Documents
Culture Documents
Security Imports System.Web.UI Imports System.Web.UI.HtmlControls Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Xml.Linq Public Partial Class _Default Inherits System.Web.UI.Page Private firstname As String = String.Empty Private lastname As String = String.Empty Private city As String = String.Empty Private designation As String = String.Empty Protected Sub Page_Load(sender As Object, e As EventArgs) End Sub Protected Sub gvDetails_RowCommand(sender As Object, e As GridViewCommandEventArgs) If e.CommandName = "Insert" Then Dim txtusername As TextBox = DirectCast(gvDetails.FooterRow.FindControl("txtftrusrname"), TextBox) Dim txtfirstname As TextBox = DirectCast(gvDetails.FooterRow.FindControl("txtftrfname"), TextBox) Dim txtlastname As TextBox = DirectCast(gvDetails.FooterRow.FindControl("txtftrlname"), TextBox) Dim txtCity As TextBox = DirectCast(gvDetails.FooterRow.FindControl("txtftrcity"), TextBox) Dim txtDesgnation As TextBox = DirectCast(gvDetails.FooterRow.FindControl("txtftrDesignation"), TextBox) sqlds.InsertParameters("UserName").DefaultValue = txtusername.Text sqlds.InsertParameters("FirstName").DefaultValue = txtfirstname.Text sqlds.InsertParameters("LastName").DefaultValue = txtlastname.Text sqlds.InsertParameters("City").DefaultValue = txtCity.Text sqlds.InsertParameters("Designation").DefaultValue = txtDesgnation.Text sqlds.Insert() lblresult.Text = txtusername.Text + " Details Inserted Successfully" lblresult.ForeColor = Color.Green End If If e.CommandName = "Update" Then
Dim gvrow As GridViewRow = DirectCast(DirectCast(e.CommandSource, ImageButton).NamingContainer, GridViewRow) Dim lblusername As Label = DirectCast(gvrow.FindControl("lbleditusr"), Label) Dim txtfirstname As TextBox = DirectCast(gvrow.FindControl("txtfname"), TextBox) Dim txtlastname As TextBox = DirectCast(gvrow.FindControl("txtlname"), TextBox) Dim txtCity As TextBox = DirectCast(gvrow.FindControl("txtcity"), TextBox) Dim txtDesgnation As TextBox = DirectCast(gvrow.FindControl("txtDesg"), TextBox) sqlds.UpdateParameters("FirstName").DefaultValue = txtfirstname.Text sqlds.UpdateParameters("LastName").DefaultValue = txtlastname.Text sqlds.UpdateParameters("City").DefaultValue = txtCity.Text sqlds.UpdateParameters("Designation").DefaultValue = txtDesgnation.Text sqlds.Update() lblresult.Text = lblusername.Text + " Details Updated Successfully" lblresult.ForeColor = Color.Green End If If e.CommandName = "Delete" Then Dim gvdeleterow As GridViewRow = DirectCast(DirectCast(e.CommandSource, ImageButton).NamingContainer, GridViewRow) Dim lblusername As Label = DirectCast(gvdeleterow.FindControl("lblitemUsr"), Label) lblresult.Text = lblusername.Text + " Details Updated Successfully" lblresult.ForeColor = Color.Red End If End Sub End Class