I got a datagrid that supposed to edit the datagrid once the user clicks on edit button next to each record. I want this page recives the record number as passed value but i do not know how to do it .(datagridupdate?record=4)
Is there a way to pass record value to this part of code which is resposible for finding the record that we want to update ? I be happy to get some help here. thanks
Sub DBEditDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
DBEditDataGrid.EditItemIndex = E.Item.ItemIndex
DataBindGrid
End Sub
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="VB" runat="server">
Dim objConnection As SqlConnection
Dim myDataReader As SqlDataReader
Sub Page_Load(Sender As Object, E As EventArgs)
' Set up our connection.
objConnection = New SqlConnection("Data Source=(local);" _
& "Initial Catalog=teniss2;User Id=web;Password=web;" _
& "Connect Timeout=15;Network Library=dbmssocn;")
LoadDataFromDB
If Not IsPostBack Then
DataBindGrid
End If
End Sub
Sub LoadDataFromDB()
Dim objCommand As SqlCommand
' Create new command object passing it our SQL query
' and telling it which connection to use.
objCommand = New SqlCommand("SELECT * FROM Players;", objConnection)
' Open the connection, execute the command, and close the connection.
objConnection.Open()
myDataReader = objCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
End Sub
Sub DataBindGrid()
DBEditDataGrid.DataSource = myDataReader
DBEditDataGrid.DataBind
End Sub
Sub DBEditDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
DBEditDataGrid.EditItemIndex = E.Item.ItemIndex
DataBindGrid
End Sub
.......
.......
Is there a way to pass record value to this part of code which is resposible for finding the record that we want to update ? I be happy to get some help here. thanks
Sub DBEditDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
DBEditDataGrid.EditItemIndex = E.Item.ItemIndex
DataBindGrid
End Sub
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="VB" runat="server">
Dim objConnection As SqlConnection
Dim myDataReader As SqlDataReader
Sub Page_Load(Sender As Object, E As EventArgs)
' Set up our connection.
objConnection = New SqlConnection("Data Source=(local);" _
& "Initial Catalog=teniss2;User Id=web;Password=web;" _
& "Connect Timeout=15;Network Library=dbmssocn;")
LoadDataFromDB
If Not IsPostBack Then
DataBindGrid
End If
End Sub
Sub LoadDataFromDB()
Dim objCommand As SqlCommand
' Create new command object passing it our SQL query
' and telling it which connection to use.
objCommand = New SqlCommand("SELECT * FROM Players;", objConnection)
' Open the connection, execute the command, and close the connection.
objConnection.Open()
myDataReader = objCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
End Sub
Sub DataBindGrid()
DBEditDataGrid.DataSource = myDataReader
DBEditDataGrid.DataBind
End Sub
Sub DBEditDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
DBEditDataGrid.EditItemIndex = E.Item.ItemIndex
DataBindGrid
End Sub
.......
.......