| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 594 人关注过本帖
标题:急急急!!!!!!!!添加页码模式和数字模式后那里的编辑(更新,取消)不能打开了
只看楼主 加入收藏
twtdd
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2008-6-12
收藏
 问题点数:0 回复次数:1 
急急急!!!!!!!!添加页码模式和数字模式后那里的编辑(更新,取消)不能打开了
Function CreateDataSet(ByVal strSQL As String, ByVal FileName As String, ByVal TableName As String) As DataSet
        Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(FileName)
        Dim objCmd As New OleDbDataAdapter(strSQL, ConnString)
        Dim DS As New DataSet
        objCmd.Fill(DS, TableName)
        CreateDataSet = DS
    End Function
    Sub BindList()

        DataGrid1.DataSource = CreateDataSet("select * from book", "Mydb.mdb", "book")

        DataGrid1.DataBind()
    End Sub
    Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not IsPostBack Then BindList()
        If RadioButton1.Checked Then
            DataGrid1.PagerStyle.Mode = PagerMode.NextPrev
            DataGrid1.PagerStyle.PrevPageText = "上一页"
            DataGrid1.PagerStyle.NextPageText = "下一页"
        Else
            DataGrid1.PagerStyle.Mode = PagerMode.NumericPages
        End If
        BindList()

    End Sub

    Sub DataGrid_EditCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
        DataGrid1.EditItemIndex = e.Item.ItemIndex
        BindList()
    End Sub

    Sub DataGrid_CancelCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
        DataGrid1.EditItemIndex = -1
        BindList()
    End Sub


    Private Sub DataGrid1_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)

        Dim aa As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
        Dim bb As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
        Dim cc As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
        Dim dd As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text

        Dim strSQL As String
        strSQL = "Update book Set 代号= ' " & aa & " ', 刊名=' " & bb & " ', 类别=' " & cc & " ',刊期=' " & dd & " ' Where " & DataGrid1.DataKeyField & "=" & DataGrid1.DataKeys(e.Item.ItemIndex)

        Dim objConn As New OleDbConnection
        objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Mydb.mdb")
        objConn.Open()
        Dim objCmd As New OleDbCommand(strSQL, objConn)
        objCmd.ExecuteNonQuery()
        DataGrid1.EditItemIndex = -1
        BindList()


    End Sub



    Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
        DataGrid1.CurrentPageIndex = e.NewPageIndex
        BindList()

    End Sub
End Class

[[it] 本帖最后由 twtdd 于 2008-6-15 01:25 编辑 [/it]]

未命名.jpg (1.06 MB)
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 页码 Microsoft 数字 模式 String 
2008-06-15 01:23
twtdd
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2008-6-12
收藏
得分:0 
未命名的图是上题图
2008-06-15 01:26
快速回复:急急急!!!!!!!!添加页码模式和数字模式后那里的编辑(更新,取消)不能打 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046584 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved