[求助]帮忙翻译解释下
帮帮我啊,不然我没法做下去了!!!_________________________________________________________
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If Not Page.IsPostBack Then
Call BindData() '启动页面时调用数据绑定子程序
End If
End Sub
'单击编辑时,执行该事件过程。
Sub MyDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
MyDataGrid.EditItemIndex = CInt(E.Item.ItemIndex)
Call BindData()
_______________________________________________________________________________________
问题: 这句是什么意思MyDataGrid.EditItemIndex = CInt(E.Item.ItemIndex),他的作用是什么CInt(E.Item.ItemIndex)
____________________________________________________________________________________
Sub MyDataGrid_Cancel(Sender As Object, E As DataGridCommandEventArgs)
MyDataGrid.EditItemIndex = -1
Call BindData()
___________________________________________________________________________________
问题:他的作用是什么:MyDataGrid.EditItemIndex = -1
___________________________________________________________________________________
End Sub
'单击更新时,执行该事件过程。
Sub MyDataGrid_Update(Sender As Object, E As DataGridCommandEventArgs)
'建立Connection对象
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("wwwlink.mdb"))
'建立Command对象
Dim txtSiteName,txtURL,txtIntro,txtGrade As textbox '声明文本框控件变量
txtSiteName=e.Item.Cells(2).Controls(0)
txtURL=e.Item.Cells(3).Controls(0)
txtIntro=e.Item.Cells(4).Controls(0)
txtGrade=e.Item.Cells(5).Controls(0)
Dim strSql As String
strSql="Update link Set sitename='" & txtSiteName.Text & "',URL='" & txtURL.Text & "',intro='" & txtIntro.Text & "',grade=" & CInt(txtGrade.Text) & ",submit_date=#" & Now() & "# Where link_id=" & MyDataGrid.DataKeys(CInt(E.Item.ItemIndex))
Dim cmd As New OleDbCommand(strSql, conn)
'执行更新操作
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
'重新绑定
MyDataGrid.EditItemIndex = -1
Call BindData()
End Sub
'数据绑定子程序,供其它过程调用
Sub BindData()
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("wwwlink.mdb")) '建立Connection对象
Dim cmd As New OleDbCommand("select * from link", conn) '建立Command对象
Dim adp As New OleDbDataAdapter(cmd) '建立DataAdapter对象
Dim ds As New DataSet() '建立DataSet对象
adp.Fill(ds, "link") '填充DataSet
MyDataGrid.DataSource=DS.Tables("link").DefaultView '指定数据源
MyDataGrid.DataBind() '执行绑定
End Sub
</script>
<html>
<body>
<h4 align="center">更新记录</h4>
<center>
<form runat="server">
<ASP:DataGrid id="MyDataGrid" Width="95%" HeaderStyle-BackColor="#BCBCBC" OnEditCommand="MyDataGrid_Edit" OnCancelCommand="MyDataGrid_Cancel" OnUpdateCommand="MyDataGrid_Update" DataKeyField="link_id" runat="server">
<Columns>
<asp:EditCommandColumn EditText="编辑" UpdateText="更新" CancelText="取消" ItemStyle-Wrap="False"/>
</Columns>
</ASP:DataGrid>
</form>
</center>
</body>
</html>