file:///C:\Users\j\Desktop\WebSite\User.aspx.vb


Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub GridView1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.Load
        If IsPostBack Then
            Return
        End If
        Using sds As SqlDataSource = New SqlDataSource("data source=192.168.0.44;initial catalog=master;user id=sa;password=Abc2008def", "select * from t_user")
            Me.GridView1.AllowPaging = True
            Me.GridView1.AutoGenerateDeleteButton = True
            Me.GridView1.AutoGenerateEditButton = True
            Me.GridView1.AutoGenerateSelectButton = True
            Me.GridView1.DataKeyNames = New String() {"p_user_id"}
            Me.GridView1.DataSource = sds
            Me.GridView1.DataBind()
        End Using
    End Sub

    Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        Using sds As SqlDataSource = New SqlDataSource("data source=192.168.0.44;initial catalog=master;user id=sa;password=Abc2008def", "select * from t_user")
            Me.GridView1.PageIndex = e.NewPageIndex
            Me.GridView1.EditIndex = -1
            Me.GridView1.DataSource = sds
            Me.GridView1.DataBind()
        End Using
    End Sub

    Protected Sub GridView1_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit
        Using sds As SqlDataSource = New SqlDataSource("data source=192.168.0.44;initial catalog=master;user id=sa;password=Abc2008def", "select * from t_user")
            Me.GridView1.EditIndex = -1
            Me.GridView1.DataSource = sds
            Me.GridView1.DataBind()
        End Using
    End Sub

    Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
        Dim p_user_id As String = Me.GridView1.DataKeys(e.RowIndex).Values("p_user_id").ToString()
        Using sds As SqlDataSource = New SqlDataSource("data source=192.168.0.44;initial catalog=master;user id=sa;password=Abc2008def", "select * from t_user")
            sds.DeleteCommand = "delete from t_user where p_user_id = @p_user_id"
            sds.DeleteParameters.Add("p_user_id", p_user_id)
            sds.Delete()
            Me.GridView1.EditIndex = -1
            Me.GridView1.DataSource = sds
            Me.GridView1.DataBind()
        End Using
    End Sub

    Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
        Using sds As SqlDataSource = New SqlDataSource("data source=192.168.0.44;initial catalog=master;user id=sa;password=Abc2008def", "select * from t_user")
            Me.GridView1.EditIndex = e.NewEditIndex
            Me.GridView1.DataSource = sds
            Me.GridView1.DataBind()
        End Using
    End Sub

    Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
        Dim tb_username As TextBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(1).Controls(0), TextBox)
        Dim tb_userpass As TextBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(2).Controls(0), TextBox)
        Dim cb_a As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(3).Controls(0), CheckBox)
        Dim cb_b As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(4).Controls(0), CheckBox)
        Dim cb_c As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(5).Controls(0), CheckBox)
        Dim cb_d As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(6).Controls(0), CheckBox)
        Dim cb_e As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(7).Controls(0), CheckBox)
        Dim cb_f As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(8).Controls(0), CheckBox)
        Dim cb_g As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(9).Controls(0), CheckBox)
        Dim cb_h As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(10).Controls(0), CheckBox)
        Dim cb_i As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(11).Controls(0), CheckBox)
        Dim cb_j As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(12).Controls(0), CheckBox)
        Dim cb_k As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(13).Controls(0), CheckBox)
        Dim cb_l As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(14).Controls(0), CheckBox)
        Dim cb_m As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(15).Controls(0), CheckBox)
        Dim cb_n As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(16).Controls(0), CheckBox)
        Dim cb_o As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(17).Controls(0), CheckBox)
        Dim cb_p As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(18).Controls(0), CheckBox)
        Dim cb_q As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(19).Controls(0), CheckBox)
        Dim cb_r As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(20).Controls(0), CheckBox)
        Dim cb_s As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(21).Controls(0), CheckBox)
        Dim cb_t As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(22).Controls(0), CheckBox)
        Dim cb_u As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(23).Controls(0), CheckBox)
        Dim cb_v As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(24).Controls(0), CheckBox)
        Dim cb_w As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(25).Controls(0), CheckBox)
        Dim cb_x As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(26).Controls(0), CheckBox)
        Dim cb_y As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(27).Controls(0), CheckBox)
        Dim cb_z As CheckBox = DirectCast(Me.GridView1.Rows(e.RowIndex).Cells(28).Controls(0), CheckBox)
        Dim p_user_id As String = Me.GridView1.DataKeys(e.RowIndex).Values("p_user_id").ToString()
        Using sds As SqlDataSource = New SqlDataSource("data source=192.168.0.44;initial catalog=master;user id=sa;password=Abc2008def", "select * from t_user")
            sds.UpdateCommand = "update t_user set username = @username, userpass = @userpass, a = @a, b = @b, c = @c, d = @d, e = @e, f = @f, g = @g, h = @h, i = @i, j = @j, k = @k, l = @l, m = @m, n = @n, o = @o, p = @p, q = @q, r = @r, s = @s, t = @t, u = @u, v = @v, w = @w, x = @x, y = @y, z = @z where p_user_id = @p_user_id"
            sds.UpdateParameters.Add("username", tb_username.Text)
            sds.UpdateParameters.Add("userpass", tb_userpass.Text)
            sds.UpdateParameters.Add("a", cb_a.Checked)
            sds.UpdateParameters.Add("b", cb_b.Checked)
            sds.UpdateParameters.Add("c", cb_c.Checked)
            sds.UpdateParameters.Add("d", cb_d.Checked)
            sds.UpdateParameters.Add("e", cb_e.Checked)
            sds.UpdateParameters.Add("f", cb_f.Checked)
            sds.UpdateParameters.Add("g", cb_g.Checked)
            sds.UpdateParameters.Add("h", cb_h.Checked)
            sds.UpdateParameters.Add("i", cb_i.Checked)
            sds.UpdateParameters.Add("j", cb_j.Checked)
            sds.UpdateParameters.Add("k", cb_k.Checked)
            sds.UpdateParameters.Add("l", cb_l.Checked)
            sds.UpdateParameters.Add("m", cb_m.Checked)
            sds.UpdateParameters.Add("n", cb_n.Checked)
            sds.UpdateParameters.Add("o", cb_o.Checked)
            sds.UpdateParameters.Add("p", cb_p.Checked)
            sds.UpdateParameters.Add("q", cb_q.Checked)
            sds.UpdateParameters.Add("r", cb_r.Checked)
            sds.UpdateParameters.Add("s", cb_s.Checked)
            sds.UpdateParameters.Add("t", cb_t.Checked)
            sds.UpdateParameters.Add("u", cb_u.Checked)
            sds.UpdateParameters.Add("v", cb_v.Checked)
            sds.UpdateParameters.Add("w", cb_w.Checked)
            sds.UpdateParameters.Add("x", cb_x.Checked)
            sds.UpdateParameters.Add("y", cb_y.Checked)
            sds.UpdateParameters.Add("z", cb_z.Checked)
            sds.UpdateParameters.Add("p_user_id", p_user_id)
            sds.Update()
            Me.GridView1.EditIndex = -1
            Me.GridView1.DataSource = sds
            Me.GridView1.DataBind()
        End Using
    End Sub
End Class

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值