I need assistance writing my code-behind logic for my Update Command event for a stored procedure.
I have a SQL server 2000 table that looks like this…
Both data types are char.
I have a stored procedure that looks like this…
Here is my current code behind…
Thanks in advance for taking the time.
Tim
I have a SQL server 2000 table that looks like this…
Code:
Status_Id Status_Description
A Active
P Planned
Both data types are char.
I have a stored procedure that looks like this…
Code:
create procedure dbo.usp_Update_Status_Master
(
@status_id char(1),
@status_description char(30)
)
as
update status_master
set status_description = @status_description
where status_id = @status_id
GO
Here is my current code behind…
Code:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Data.Odbc
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Call LoadStatusMasterGrid()
End If
End Sub
Public Sub LoadStatusMasterGrid()
Dim connection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("sqlConn"))
connection.Open()
Try
Dim command As SqlCommand = _
New SqlCommand("usp_Select_Status_Master", connection)
Command.CommandType = CommandType.StoredProcedure
Dim adapter As SqlDataAdapter = New SqlDataAdapter(Command)
Dim table As DataTable = New DataTable
adapter.Fill(table)
dgStatusMaster.DataSource = table
dgStatusMaster.DataKeyField = "status_id"
dgStatusMaster.DataBind()
Catch ex As Exception
Console.WriteLine(ex.Message)
Throw
Finally
connection.Close()
End Try
End Sub
Private Sub dgStatusMaster_EditCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgStatusMaster.EditCommand
dgStatusMaster.EditItemIndex = e.Item.ItemIndex
dgStatusMaster.DataBind()
Call LoadStatusMasterGrid()
End Sub
Private Sub dgStatusMaster_CancelCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgStatusMaster.CancelCommand
dgStatusMaster.EditItemIndex = -1
Call LoadStatusMasterGrid()
End Sub
Private Sub dgStatusMaster_UpdateCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgStatusMaster.UpdateCommand
‘ How do I code this part?
End Sub
End Class
Thanks in advance for taking the time.
Tim